std::remove_reference explained?

why is it that there are specializations for lvalue and rvalue reference? If only the primary template existed, then doing: remove_reference<int&>::type Would give you: int& And doing: remove_reference<int&&>::type Would give you: int&& Which is not what you want. The specializations for lvalue references and rvalue references allow stripping the & and the &&, respectively, from … Read more

Specifying one type for all arguments passed to variadic function or variadic template function w/out using array, vector, structs, etc?

You can just accept the arguments by the variadic template and let typechecking check the validity later on when they are converted. You can check convertibility on the function interface level though, to make use of overload resolution for rejecting outright wrong arguments for example, by using SFINAE template<typename R, typename…> struct fst { typedef … Read more

Member template in local class

The purpose of this limitation? Just a guess, but: you may use the template class/template member function only within the enclosing function. Therefore you already know all used types within the function and hence can directly specify the used types (for several types, of course, the template variant would have saved some typing). although it … Read more

How does Eric Niebler’s implementation of std::is_function work?

The general idea Instead of listing all the valid function types, like the sample implementation over on cpprefereence.com, this implementation lists all of the types that are not functions, and then only resolves to true if none of those is matched. The list of non-function types consists of (from bottom to top): Classes and unions … Read more

C++ invoke explicit template constructor

It’s not possible. The Standard also has a note on this at 14.8.1/7 [Note: because the explicit template argument list follows the function template name, and because conversion member function templates and constructor member function templates are called without using a function name, there is no way to provide an explicit template argument list for … Read more

Why can’t the template argument be deduced when it is used as template parameter to another template?

That is non-deducible context. That is why the template argument cannot be deduced by the compiler. Just imagine if you might have specialized TMap as follows: template <> struct TMap<SomeType> { typedef std::map <double, double> Type; }; How would the compiler deduce the type SomeType, given that TMap<SomeType>::Type is std::map<double, double>? It cannot. It’s not … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)