Skip to main content

Questions tagged [templates]

The templates tag is used in multiple contexts: generic programming (especially C++), and data/document generation using template engines, web template for a pre-designed webpage, or set of HTML webpages. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

0 votes
1 answer
54 views

Unexpected 'pointer is null' warning in boost asio library?

I'm compiling a project that incorporates the asio C++ library, and I'm getting a pesky warning: ../opendnp3/_deps/asio-src/asio/include/asio/impl/connect.hpp:75:73: warning: ‘this’ pointer is null [-...
Chris's user avatar
  • 669
-1 votes
0 answers
36 views

How to write C++ template SFINAE in my case [duplicate]

template<typename VertexType> class CQuad { public: VertexType tl, bl, tr, br; void SetColor(const CColor& color) { //if VertexType has a member "color", then ...
Louis's user avatar
  • 1
-1 votes
0 answers
59 views

FSM with templates and pointers [duplicate]

Hi I'm trying to make a FSM Finite State Machine in c++ with pointers and templates. I want to simplify my code and get access to the variable of the State controller inheritted or the Game Screen ...
Bersere's user avatar
5 votes
1 answer
88 views

Weird behaviour with 'if constexpr' and templates in MSVC

The code below behaves incorrectly. When f<0> or f<5> is called, it prints as if k = true, but the if statement behaves as if k = false. When f<1> is called, it does the opposite. ...
daniel creatd's user avatar
1 vote
2 answers
54 views

Return the correct type when the template passed into a function argument changes type

NOTE: Please do NOT suggest I implement overloaded functions! I know how to do that. The point of this exercise is to learn how to work with templates. I have this function (it takes some params and ...
ConfusedCpp's user avatar
0 votes
1 answer
32 views

Making a tuple of references out of another tuple by condition

I have a templated structure ContainerInner that has a tuple with vectors of types from its variadic template and a structure Container that contains a tuple of ContainerInner, specified in its ...
SavedowW's user avatar
-1 votes
0 answers
29 views

C++ calling function template of template parameter, error "invalid operands of types" [duplicate]

#include <iostream> using namespace std; struct X { template<bool S> void foo() { cout << "foo, S:" << S << endl; } }; template<...
Andrey Rubliov's user avatar
-1 votes
2 answers
17 views

TemplateDoesNotExist by inheriting LoginView

django cannot find my template but I give it correct path I make customize view for login by inheriting LoginView and form_class of AuthenticationForm from django. I give correct template_name to view ...
Alireza Reisi's user avatar
4 votes
1 answer
99 views

correct syntax to access a template variable specialization

assume a template variable in data.h: template <class T> struct Data { Data() = delete; Data(T initValue) : value(initValue){} T value; }; template<class T> extern Data<T&...
Alexander's user avatar
  • 758
-2 votes
0 answers
26 views

C++: define function template in class template, but outside the class body [duplicate]

#include <iostream> using namespace std; template<class T> struct Handler { template<bool local> void foo() { cout << "foo" << endl; } ...
Andrey Rubliov's user avatar
-2 votes
2 answers
70 views

Add a templated attribute to a class? [closed]

I want to define a class like, template<int N> class A{ public: template<int D> B<D>* InstanceofB; void methodofClassA(input){ methodofClassB(input); } ...
Indrajit Wadgaonkar's user avatar
0 votes
0 answers
22 views

getting errors with django templates [duplicate]

I am practicing Django lately and i get this error, can someone assist Invalid block tag on line 17: 'else', expected 'endblock'. Did you forget to register or load this tag? The template {% extends '...
Peter Mbugua's user avatar
0 votes
3 answers
88 views

nested switch statements for template arguments

We have some templated function that takes 2 compile-time arguments, e.g. template<int a, int b> void SomeFunc(double *x, double *y, double *z); For performance reasons, it is better to have ...
debronee101's user avatar
2 votes
1 answer
66 views

Member pointer template parameter pointing into the object being templated

I would like to have a base class that I derive from that offers serialization mechanism: template <typename Type, typename Class, Type Class::* Member> class Serializable { public: void ...
Jeffrey's user avatar
  • 11.3k
-3 votes
1 answer
93 views

Getting error when trying to overload << operator in C++

I am trying to print a vector for logging purposes in C++. I have made a function but it's throwing an error. Can anyone please help me explain why and suggest a possible fix. Here's the code snippet #...
Ved Timbadiya's user avatar

15 30 50 per page
1
2 3 4 5
3688