2

I'm trying to define a class template that depends from a <typename T, const double and std::size_t>. I know that before C++ 14 was impossible declare a default parameter for double type in template but I read somewhere that now it's possible but I don't know how. I tried to indexing the research here and in goolge but I didn't found what I wish accomplish that is:

template <typename Type, double threshold = 0.5 , std::size_t Sz = 64>
class DynBmatrix 
{
   constexpr DynBmatrix(std::vector<std::vector<Type>> ) noexcept ;
}

template<typename T, double TH,std::size_t S>
class DynBmatrix<T,TH,S>
{
    if (something > TH) 
    ...
}

and in the main instance the template as simply

DynBmatrix<int> dbm{} ;

EDIT : solved as folow : thanks @Marco

constexpr double th = 0.5 ;

template <typename Type, const double* TH = &th , std::size_t Sz = 64>
Drudox lebowsky
  • 1,020
  • 7
  • 21
  • Possible duplicate of [Why can't I use float value as a template parameter?](https://stackoverflow.com/questions/2183087/why-cant-i-use-float-value-as-a-template-parameter) – nsubiron Dec 02 '17 at 10:21

1 Answers1

1

using : const double* TH instead of double TH and define outside the class the constexpr double th = 0.5 ; then you got the same behaviour

Marco Ghiani
  • 219
  • 1
  • 12