• Create Account

### #Actuallightxbulb

Posted 31 May 2013 - 12:39 PM

Thanks a lot guys!

Guess it's just me then not being used to templates xD

Even though it looks logical (to me) that the compiler will infer the evaluated type of the variables from the type of objects contained in the list, I guess it's not.

I mean the compiler usually will be able to "guess" what s the type if I write:

template <typename T>
bool greaterThan(const T& in1, const T& in2)
{
return in1>in2;
}


and:

int a=5, b=6;
cout << greaterThan(a,b) << endl; 

No error in this one...

Btw that's a little off-topic but can anybody with a C++11 compiler tell me if this works for him:

vector<int> myVec = {5, 13, -7};


C++ 11 should support it right? I'm on VS2012 and it seems it doesn't support some of the features for C++ 11.

### #2lightxbulb

Posted 31 May 2013 - 12:38 PM

Thanks a lot guys!

Guess it's just me then not being used to templates xD

Even though it looks logical (to me) that the compiler will infer the evaluated type of the variables from the type of objects contained in the list, I guess it's not.

I mean the compiler usually will be able to "guess" what s the type if I write:

template <typename T>
bool greaterThan(const T& in1, const T& in2)
{
return in1>in2;
}


and:

int a=5, b=6
cout << greaterThan(a,b) << endl; 

No error in this one...

Btw that's a little off-topic but can anybody with a C++11 compiler tell me if this works for him:

vector<int> myVec = {5, 13, -7};


C++ 11 should support it right? I'm on VS2012 and it seems it doesn't support some of the features for C++ 11.

### #1lightxbulb

Posted 31 May 2013 - 12:33 PM

Thanks a lot guys!

Guess it's just me then not being used to templates xD

Even though it looks logical (to me) that the compiler will infer the evaluated type of the variables from the type of objects contained in the list, I guess it's not.

Btw that's a little off-topic but can anybody with a C++11 compiler tell me if this works for him:

vector<int> myVec = {5, 13, -7};


C++ 11 should support it right? I'm on VS2012 and it seems it doesn't support some of the features for C++ 11.

PARTNERS