c++11 - C++ noexcept specification depending on data members -


this declaration ok:

void memberfunction(t& functor, double value)noexcept(noexcept(functor(value)));  

for

template<class t>  class myclass{     public:          void memberfunction(t& functor, double value)noexcept(noexcept(functor(value)));  }; 

let's myclass has functor data member:

template<class t>  class myclass{     public:          //ctor          ...          void memberfunction(double value);      private:          t functor;  }; 

i want write noexcept specification did in previous case, tried this:

void memberfunction(double value)noexcept(noexcept(functor(value)));  

but compiler tells me functor not scope. following doesn't work analogous reasons:

void memberfunction(double value)noexcept(noexcept(this->functor(value)));  

and following can't work because have classes used t lacks default constructor:

void memberfunction(double value)noexcept(noexcept(t()(value)));  

the following syntatically wrong:

void memberfunction(double value)noexcept(noexcept(t::operator(double)));  

eve though pictorically explains want.

any suggestion? moment gave specification...

std::declval<t>() simulates rvalue t instance. std::declval<t&>() simulates lvalue t instance. use in place of t().


Comments