c++ - Why does this not compile without enable_if? -
why following code not compile if remove enable_if?
template<class t, class = typename std::enable_if< std::is_constructible<t, double,double,double>::value >::type > operator t() const { return t{x, y, z}; }
example code: enable_if http://ideone.com/nwdmjh
without enable_if + compile error http://ideone.com/fbmamf
without enable_if
, conversion operator exists every type. error if attempting instantiate conversion operator types cannot constructed {x, y, z}
, doesn't change fact operator exists. because exists, type considered convertible double *
, , overload resolution cannot pick best match.
Comments
Post a Comment