Questions tagged [templates]
The templates tag has no summary.
130 questions
2
votes
4
answers
520
views
How to combine multiple functions into a single template based function
Threre are two functions FindMaxDistanceVector and FindMaxDistanceList whose implementation is almost same except some debug information added in FindMaxDistanceList. Note that these two functions are ...
1
vote
1
answer
391
views
Using templates without generic implementation
Is it a good practice to declare a template class, but only with specialized implementations ?
Ie, there are many CRC flavours (see https://en.wikipedia.org/wiki/Cyclic_redundancy_check#...
0
votes
1
answer
134
views
Identify downsides: versioning auto-generated Terraform source code [closed]
HINT: the purpose of this question is to identify downsides for the scenario described. If something is a downside, then it should be quantifiable and it should clearly have a negative impact.
...
0
votes
0
answers
93
views
What is the use case for blocks in template engines?
Most template engines have two ways to refer to other templates:
Inheritance with blocks (child template inherits from parent template and fills one or more blocks)
Includes (parent template includes ...
-1
votes
2
answers
244
views
Template Source Control Repository
What is the best practice, for creating a template repository, and then creating n projects based on that template?
With "template" I mean: Let's say the template site is x. So x is a site ...
0
votes
2
answers
232
views
How to develop data bound html with strong typing and intellisense?
I'm a huge believer in the value of Intellisense for showing you what syntax is expected and allowed (and also saving typing, though this is a secondary consideration).
When you build a web component (...
2
votes
1
answer
431
views
C++ behavior as a template argument
I would like to have a class, let's say a queue, that can be specialized to its behavior. For example, let them be a SafeQueue (which disables IRQs before any access) and a FastQueue (which doesn't). ...
1
vote
0
answers
125
views
Is it bad practice to specialize template method to implement strategy pattern in C++?
I came across a class that implements a kind of "strategy pattern" with a concrete implementation defined inside the main class as a template method.
#include <iostream>
struct ObjA {
...
1
vote
3
answers
4k
views
Is it possible to instantiate a template class at runtime?
Suppose I have two abstract classes called Color and Animal
And I can create classes Green/Red/Blue derived from Color and classes Dog/Cat/Pig derived from Animal at runtime using factory pattern.
...
7
votes
2
answers
3k
views
How to generate java class files with framework boilerplate in a project?
The Java project I am working on currently has a complicated folder structure, and to add a new functionality, one needs to add many .java files in different places in order to let it work in our ...
1
vote
1
answer
251
views
C++20, specialize struct once per type and allow member functions to take type as reference, raw, std::unique|shared_ptr or any other smart ptr
Situation
I have some existing functions which expect containers which can be iterated and which have certain value_type. The value_type can be a value or some (smart) pointer.
All the value_type have ...
-3
votes
2
answers
1k
views
Using templates to define sizes of containers?
Is using templates for specifying capacities of containers a good use or misue of the templates? Eg.
template <unsigned int Length>
class String {
public:
String();
String(String& ...
1
vote
3
answers
337
views
Design for generating/filling a document based on a template-file, while considering permissions from a database?
You have the backend for a web application. I'd like to keep this is as disconnected from specific programming lanuages as possible, but if necessary, assume we're talking about PHP.
You need to write ...
1
vote
2
answers
2k
views
Template argument type exclusion: Would this make for a useful C++ feature?
When using templates we can have T be any type upon class instantiation. If T is a specific type that needs to be handled differently or in a special way we can specialize or partial specialize that ...
1
vote
1
answer
224
views
Templates for generic code and code flexibility
I have a data which is a std::vector of a "small collection" of items of a given type struct Bunny {};.
I was vague about "small collection" because for now it's a collection of ...