Linked Questions

4 votes
3 answers
11k views

What does it mean to define a template with template <int N>, I read this from an example in a book: typedef map<int, double> row; template <int N> struct matrix; { map <int, ...
James Hallen's user avatar
  • 5,084
1 vote
2 answers
602 views

Possible Duplicate: What does template <unsigned int N> mean? Hi ! Are non-type template parameters and constants same ? Do the following code work because template parameter cannot be ...
Mahesh's user avatar
  • 34.7k
1 vote
2 answers
111 views

template <int parameter> class MyClass is the above a template specialization? I don't think so but I'm unsure of it, I didn't know templates could receive arguments as functions.. where do ...
Johnny Pauling's user avatar
0 votes
2 answers
119 views

Say that we have the following: template <class T, int i> I understand that T will be whatever type being passed to some function. But, what does the int i portion mean? Thanks.
user avatar
26 votes
5 answers
31k views

I do not understand how this piece of code (from Wikipedia) works: template <int N> struct Factorial { enum { value = N * Factorial<N - 1>::value }; }; template <> struct ...
Lazer's user avatar
  • 95.9k
8 votes
2 answers
37k views

For a university exercise, I have been asked to write a template function "print();", which takes two arguments, 1: an array of a generic type, and 2: an int specifying the size of the array. The ...
willfo's user avatar
  • 249
14 votes
2 answers
910 views

This program compiles and runs in C++ but doesn't in a number of different languages, like Java and C#. #include <iostream> using namespace std; void foo2() { cout << "foo 2.\n"; } ...
Sjoerd's user avatar
  • 187
2 votes
4 answers
4k views

I have a class template <unsigned int N> class StaticVector { // stuff }; How can I declare and define in this class a static factory method returning a StaticVector<3> object, sth like ...
quant_dev's user avatar
  • 6,243
0 votes
3 answers
700 views

I thought that a function template parameters are declared only by class identifiers, for example: template<class T1, class T2> void fun(T1 a, T2 b){} but I found other example where ...
Irbis's user avatar
  • 14.1k
2 votes
2 answers
459 views

I don't think my question is a duplicate of this one. what I try to do: template<const char* szFunctionName> class CReentranceLock { public: CReentranceLock(){} ~CReentranceLock(){} ...
Stephane Rolland's user avatar
0 votes
1 answer
344 views

I have created a generic array-like template to create arrays of different types. Now I need to get user input from a menu about which type of array they are building. I tried having the user enter a ...
Dakota Hipp's user avatar
0 votes
1 answer
95 views

recently I knew a new template usage like below template <unsigned int N> I saw the answer here What does template <unsigned int N> mean? It showed several examples includes: template<...
Peter Ye's user avatar
-2 votes
2 answers
78 views

I have a question about template function. This is my first time using template. I may lack of some basis. I am confusing about the type of variables I should use. What is the meaning of int N after ...
Yue's user avatar
  • 23
0 votes
0 answers
64 views

When I specialize an int-templated function with a negative value defined in hexadecimal, Visual Studio 2010 give me a strange "1 unresolve externals" link error. Still it works fine if: I define the ...
Charly's user avatar
  • 19