C++ template argument with expression -
i having trouble c++. want able put expression inside template argument. here code:
#include <vector> using namespace std; vector< ((1>0) ? float : int) > abc() { } int main(void){ return 0; }
this gives me error:
main.cpp:11:14: error: template argument 1 invalid
main.cpp:11:14: error: template argument 2 invalid
main.cpp:11:15: error: expected unqualified-id before ‘{’ token
in end want able replace 1 , 0 whatever , float , int typename t , u. why think there 2 arguments? , how solve this?
(sorry if duplicate did have solutions)
use std::conditional
:
#include <type_traits> std::vector<std::conditional<(1 > 0), float, int>::type> abc() {}
Comments
Post a Comment