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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -