Calling template function within template class

obj.bar<double>(1,2); // This line is faulty. The template keyword is required here, as obj is an instance of a type Foo<T> which depends on the template parameter T, and so the above should be written as: obj.template bar<double>(1,2); //This line is corrected ๐Ÿ™‚ Read @Johannes’s answer here for detail explanation: Where and why do I … Read more

How do I restrict a template class to certain built-in types?

In your first example, static_assert should take a second parameter which would be a string literal, otherwise it’s deemed to fail (edit: dropping the the second parameter is legal since C++17). And this second argument cannot be defaulted. Your second example is incorrect for several reasons: decltype is meant to be used on an expression, … Read more

Function Templates vs. Auto Keyword

In a nutshell, auto cannot be used in an effort to omit the actual types of function arguments, so stick with function templates and/or overloads. auto is legally used to automatically deduce the types of variables: auto i=5; Be very careful to understand the difference between the following, however: auto x=… auto &x=… const auto … Read more

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