Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [template]

a design structure for creating several things that are almost identical but need different values. Not template-meta-programming.

0
votes
0answers
8 views

Optimizing Datatables table of tens of thousands of client-provided rows

Scenario We have this employees table, that looks like this: that contains 16,530 employee rows. As expected, this table takes more than 30 seconds to load. I have been tasked with speeding it up ...
2
votes
1answer
46 views

Loop over whole array starting from any index

I recently had to repeatedly iterate over an array but increment the index to start from each time. Since this is quite cumbersome in comparison to a normal for loop I made a small template function ...
3
votes
1answer
58 views

Implementation of static_vector using an array of std::aligned_storage, with std::launder and forwarding

I'm trying to expand on the implementation of static_vector on the std::aligned_storage reference page, but would like to split it into two parts. First, an ...
3
votes
2answers
69 views

Simple Matrix Template Class

I wanted to make a matrix template class to see if I can learn how to use templates, work on figuring out the indexing in loops, and making an interface so the user can know if an operation will work. ...
1
vote
0answers
22 views

Displaying Singapore bus arrival times using a Go template

I am wondering whether my template usage in main.go could be better. For example in other code I notice: ...
2
votes
0answers
44 views

Observer(Event) system (Signals and Slots), type and template based

Signals are represented as types. You can connect a member function of some instance to the Observer system. This connected function will be called whenever a signal of a type that is the same type as ...
4
votes
0answers
49 views

Tracker for object construction, copy, and movement

I made an object tracker for debugging and testing purposes called ccm_counter (construction, copy, move counter). It counts constructor, copy and move calls. It ...
0
votes
1answer
23 views

Injecting a set of files in a Thymeleaf template while keeping the amount of tags at a minimum

I use a Thymeleaf template to inject a set of files (which contain precalculated HTML) into one big HTML. The files with their metadata are stored in a map called ...
2
votes
0answers
26 views

vb.net Create textfile from template

What is the best approach for creating textfiles from/with a template ? Currently I just read the template from a textfile and Replace all values needed, but I don't think that this is the most solid ...
1
vote
1answer
48 views

Simple template engine in PHP

I tried writing my very first template engine today. I designed it to just replace variables in templates, and keep it basic for now. Can anyone give me some constructive criticism? I'm getting ...
5
votes
2answers
52 views

add_const or remove_const based on another type

Here is a type trait which - I feel - could fit in std next to std::add_const and ...
5
votes
2answers
108 views

C++ wrapper class to mimic a C array's brace initialization

I have an inheritance class that mimics the behavior of C style array's brace initialization by using a class template that has a variadic constructor but the template itself is not a variadic ...
1
vote
1answer
81 views

Template matrix class, second version

This is my first matrix class which I updated after already asking here already. The updated code is below. Are there any suggestions regarding member function parameters? Is there a convenient ...
6
votes
2answers
109 views

First template class - Matrix functions

This post has been answered and updated. This was the first time I've ever written a template class. I've spent probably a bunch of times re-writing matrix code for different types, different ...
1
vote
0answers
56 views

A basic multi-dimensional array

I have been lurking on the C++ side of stack-overflow only long enough to know there are a lot of beginners and intermediate programmers baffled by multi-dimensional arrays. I've seen a lot of ...
10
votes
1answer
739 views

C++ math vector template

I wrote a basic template for a vector of arbitrary dimension to be used in a 3D-engine. Most operators make use of C++ template meta programming and instances are implicitly convertible to glm types. ...
3
votes
2answers
72 views

C++ Vector with templates

I am learning about templates in C++ so I decided to implement an N-dimensional vector. The code seems to work fine, but there are a few things that I am unsure about. To stop ...
4
votes
2answers
117 views

Templated string formatting

This function formats a string by replacing every occurrence of '{n}' with the corresponding argument that was passed to the function where n is an index that ...
2
votes
1answer
118 views

C++ - Trie Implementation

I am trying to learn trie and this is my first implementation. I started off with the idea of being able to handle different data types for key and value; however, I found the data structure a bit ...
2
votes
1answer
65 views

Synchronized template wrapper class

Issue: Code base has lots of data structures which are accessed between threads with >= 1 writer. Application logic becomes obfuscated due to lots of mutex locks. Solution: Create a template ...
0
votes
1answer
36 views

PHP simple template loader

This is not really a question but I'd like to obtain some opinions about this simple class. For an old project I had the necessity to load some php template files that includes some ...
-2
votes
1answer
57 views

Is this a good/bad/ugly way of assigning unique IDs to objects in C++? [closed]

My project has many different objects from different classes, and I want each object to have a unique ID. IDs should be unique within each class type, but can be the same among different classes. For ...
1
vote
0answers
127 views

A simple and efficient packet frame encoder/decoder

I have written a simple packet-framing class, for converting un-encoded 'packets' into encoded/delimited 'frames,' to be sent over a P2P serial connection. The functionality is based on the RFC 1662 "...
4
votes
2answers
250 views

Doubly linked list std::unique_ptr template class implementation

Inspired by the talk of Herb Sutter in CppCon2016, I decided to make a doubly linked list using templates, smart pointers, and raw pointers (for back-pointers, having a cycle of ...
6
votes
2answers
380 views

Small Formatting Library

I am learning C++ and currently playing with variadic template functions and formatting string, So here is my small attempt to write a formatting function and provide a simple iostream-like interface ...
6
votes
1answer
124 views

Generic Producer-Consumer in C++11

I wrote the following simple 1 producer - 1 consumer problem, in attempt to learn some C++11 threading / generics. ...
2
votes
1answer
33 views

Implement metaclass for Maximumlikelihood estimator

For the purpose of defining a lot of Maximum Likelihood estimators, I think I need a metaclass. At the moment I have to copy/paste a lot of code for every new class definition and just substitute the ...
8
votes
3answers
1k views

Templated CSV file parser

I want to parse a CSV file and store the data using the istream >> operator but I am running into big performance issues. Here is the current version: ...
2
votes
2answers
108 views

C++ Software cache for shared resources

I wrote a basic C++ template to manage shared resources like textures and shaders in a 3D engine. The idea is that the cache itself holds weak references to the resources (through ...
2
votes
2answers
84 views

Basic PHP template loader

For a project, I need to write a basic template manager who will be responsible to load the requested HTML or PHP template when the user clicks on a menù link. It's like a page loader since that all ...
3
votes
1answer
40 views

D minMax function implementation

I happened to need to find both the maximum and the minimum of an array, so I decided to implement a minMax function in D. Questions: Is this an efficient ...
4
votes
1answer
122 views

Templated byte streaming

I often have the need to take some type and stream it to something as a sequence of character byte values, so I came up with this to accomplish the task: ...
4
votes
3answers
166 views

Basic binary number container

Summary: a templated class, whose main purpose is to store a binary representation of a decimal number. I choose array of booleans as a storage, since bitset was forbidden. One of the requirements was ...
1
vote
0answers
32 views

Type conversion between Node, Const_node, and their views

Each node is a location within a layer. A Location may be a pointer or an index. A Layer is a container. There are 4 types of ...
1
vote
0answers
55 views

Type System for Layers and Nodes

Overview The following is a type system of layers (A, B, C, ...
4
votes
3answers
575 views

C++ instance counter

I have created template class to easily get the current number of instances a class has. It's threadsafe and I tried to make it as hard as possible to abuse. ...
11
votes
1answer
107 views

Composable by-member comparison

Motivation Quite often, I find myself creating types that must be compared memberwise. For example, consider this simple Person: ...
12
votes
3answers
2k views

“contains” function for STL containers

I have made a simple program that tests if the given element exists in any STL container. The program tests if the container has a find member function. It will use ...
1
vote
2answers
132 views

C# style Event and Delegate in C++

I'd appreciate advice regarding both the implementation detail and ways to improve usage/performance/generic. There are two parts: XDelegate, which is I got from ...
0
votes
2answers
98 views

Reach C++ policy-based common interface with different template parameters from one container

Please review my solution for the following problem. I am interested in: What do you think of the design Improvement tips Usability Efficiency Problem: Need to be store policy-based objects with ...
4
votes
1answer
107 views

Math Vector Header Library Templated on Data Type and Size

I have created a vector math header library where the size and data type stored are template values, and I'd like it peer-reviewed please. I have a few main questions: Will using my SizedVectorBase ...
4
votes
1answer
370 views

Generic message system using variadic templates

in my spare time I´m creating a hobby game engine as decided to write some of my systems on my own. As the time passes I´ve decided to start publishing it as a independent libraries for use (so ...
8
votes
3answers
390 views

Generators and Distributions 2.0

In my original question: Generically encapsulating random generators and distributions into a class template I was given some excellent suggestions from two very informative users. I will give a basic ...
3
votes
1answer
59 views

JavaScript module to filter data and render it as a table

I want to organize some JavaScript code using module pattern. The scenario is as follows: Having the following html table created dynamically ...
4
votes
3answers
90 views

Generically encapsulating random generators and distributions into a class template

I previously had a set of classes in one of my older libraries for working with the random number generators and distributions that was written when Visual Studio 2008 - 2010 were commonplace and ...
4
votes
1answer
316 views

JavaScript module to render and handle a form to add users

I recently switched to modular JavaScript and really like the idea of having the state of your application in JavaScript and not in the DOM. I want to know if what I am doing is considered best ...
0
votes
1answer
129 views

Vector classes implementation in C++

i have rewritten a vector classes similar to the glm library which is used mostly in opengl application. i would like to know how can i improve it further ? Types.hpp ...
10
votes
0answers
1k views

Lock-free atomic shared pointer in C++14

I'm trying to write a lock-free implementation for atomic shared pointer. Basically, there are two class templates shared_ptr and ...
4
votes
1answer
196 views

Flask web application, with handling for user login status

I am trying to change some variable in base html-template which other html pages inherite from after entering user in personal account. The idea is as follows: there is base html template and there ...
7
votes
1answer
557 views

C++ reduce repetitions of code for similar classes

I have the following two classes to make appending strings - and wstrings respectively - easier: ...