шаблоны-с++

Function overloading and templates in C++

In pursuit of the question of function overloading: C++ Using function overloading, write a program for calculating the prod ... ade function overloading unnecessary (in C++)? Or are there still options where templates can't replace function overloading?

Explicit instantiation of a template constructor and a member function

To use a template class defined in the .cpp file, you can explicitly instantiate this class: template<typename T> stru ... iating it, everything works without errors, but without explicitly instantiating the function, its use gives a linking error.

C++List Template

There is a doubly linked list, you need to make a template for it so that you can interact with different types of data, tell ... v->next = NULL; pv->prev = NULL; return pv; }; Underscores Node* with error: missing argument list for "Node".

How to pass a C++class (structure) template to a function template

There is a structure template template<typename T> struct spec { T* values; int size = 0; }; You need to make ... ze] = val; st->size = st->size + 1; } But the error is отсутствует список аргументов для параметр шаблона template

Array library, entering the size of an array from the keyboard

Is there any way, using array (int, N) name; to enter the size of the array (N)from the keyboard?

How do I choose a null value for the base types in the template?

How to choose a value for basic types int32_t, int8_t etc. for a template class? That is, that the const bool is_empty() con ... gt; inline const bool point_base<__type>::is_empty() const noexcept { // выполнить проверку что значение нулевое }

What is the meaning of std::forward when passing parameters?

What is the difference between the following two ways of passing parameters? template <typename ...Args> smth(Args &am ... (args...) {} template <typename ...Args> smth(Args &&...args) : base(std::forward<Args>(args)...) {}

Template method for c++containers

There is a method void SortVector(vector<int>& vec, int topV, bool wozrastanie) I want to make it a template to ... vec, int topV, bool wozrastanie) Is it possible to solve the problem without rewriting the same method for each container?

Take out a template class method в.срр

How do I move a template class method from a header to a cpp ?

C++, virtual methods in templates, and inheritance

Please tell me, is it correct in C++ to make a class template that has virtual methods? Especially, purely virtual ones: te ... l behave correctly. Especially when inheriting in different translation units. Say what Стандарт says about this about what?

How can I use using to declare a member type inside a template class?

Consider the following code: class A { public: using Uptr = std::unique_ptr<A>; }; class B { public: A ... T> class B { public: A<T>::Uptr a;// Error }; Tell me why this is happening, and what can be done about it?

Error C2039: Path Head: is not a member of " Lst Paths"

Hello, I'm trying to fill out a list of lists, but an error pops up. There are 2 lists available: struct Lst_Paths { char ... at prevents entering this function 3 times. But the error remained, I do not know what to do. Please do not offer STL lists.

Template function

There is a template function: template <class T1, class T2> void function(T1 a, T1 b, T2 c) { ... } It is required ... ns an error. As I understand it, it's the second parameter of the template. You need to somehow also give it a default value.

What is a template, how and why?

What is a template in C++? For what purposes is it used? How is it used? - It would be desirable to use an example.

Compilation error "no matching function for call" and unexplained " solution"

I make a universal container template to store objects not only in memory and to work with 'Range-based for loop' (that is, i ... emoryContainer<int, int> container; IContainer<int, int> *_container1 = new MemoryContainer<int, int>(); }

Function Template parameters

Here is a simple function template that returns a doubled value. But I can only write numbers to the parameters? (int, double ... ate< class TYPE > void PrintTwice(TYPE data) { cout << "Double meaning: " << data * 2 << endl; }

How do I pass a function template to another function?

How to write the function test correctly, so that it can pass any of the functions f and g as an argument (or a template para ... ^ prog.cpp: In function 'int main()': prog.cpp:26:8: error: 'test' was not declared in this scope test(f); ^

Enabling templates and std:: enable if

This is a sample code from the site cppreference.com. Which of the three options for enabling overloaded foo options is prefe ... бка времени компиляции foo2(7); // OK // A<int> a1; // ошибка времени компиляции A<double> a1; // OK }

Template as a template parameter

How do I pass a template as a parameter to another template? template < typename T > struct A{}; template < templ ... se different template specializations in the template, but the compiler only allows you to insert the{[2] class itself]}