c++ - Default argument for STL container in templated function -



c++ - Default argument for STL container in templated function -

i have templated function of form

template <typename t> void my_fct( vector<t> ){...}

and provide default argument, such my_fct() can called. clearly, compiler not know type "t" in case, there way give default type in case?

i tried pass empty vector of type double

template <typename t> void my_fct( vector<t> = vector<double> ){...}

but not work.

thanks!

make t default argument:

template <typename t = double> void my_fct( vector<t> = vector<t>() ) {...}

so when user calls function 0 arguments, type of vector std::vector<double> initialized default argument.

c++ templates stl

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -