Lambda passed to template not defined

It seems to me this is a compiler glitch. Using Clang compiler of Visual Studio 2017 only this error is generated “cannot refer to class template ‘foo’ without a template argument list” for a and b instantiation in main function. If the function type is specified as template parameter, there are no warnings and no … Read more

Why does adding const turn a forwarding reference into an rvalue reference?

The official name is not universal reference, but forwarding reference. The Standard states that only rvalue references to cv-unqualified template parameters fall in this category: 14.8.2.1 Deducing template arguments from a function call [temp.deduct.call] 3 If P is a cv-qualified type, the top level cv-qualifiers of P’s type are ignored for type deduction. If P … Read more

C++11: Why is private member template accessible outside class?

This is definitely a compiler bug, and actually one that has been known for quite some time: GCC #47346 (first reported in Jan 2011) and Clang #15914 (first reported May 2013). Your __tklass is clearly private, and the template alias is not marked friend, so this should be a simple access error. The simplest reproduction … Read more

Pointer to class member as a template parameter

In c++17, with the addition of auto in template arguments (P0127), I think you can now do: template<auto value> struct MyStruct {}; template<typename Class, typename Result, Result Class::* value> struct MyStruct<value> { // add members using Class, Result, and value here using containing_type = Class; }; typename MyStruct<&Something::theotherthing>::containing_type x = Something();

What is the reason for `std::result_of` deprecated in C++17?

T.C. already provided the obvious link, but perhaps the most horrific reason bears repeating: result_of involved forming the type F(Arg1, Arg2, …) not for a function of those types returning F but for a function of type F accepting those types. (After all, the return type is the result of, well, result_of, not the input!) … Read more

Use of typename keyword with template function parameters

If you slightly change your declaration, you get an entire different story template <class T> void foo(T::type& v); That isn’t unambiguous anymore. It could declare a variable of type void that is initialized by a bit-wise AND expression. The entire declaration would be templated. Of course, this semantically is all nonsense, but it syntactically is … Read more

Explicit specialization in non-namespace scope does not compile in GCC

This should be a GCC bug. Full specialization should be allowed in any scope, including in class definition. According to CWG 727, [temp.expl.spec] paragraph 2 was changed from (emphasis mine) An explicit specialization shall be declared in a namespace enclosing the specialized template. An explicit specialization whose declarator-id or class-head-name is not qualified shall be … Read more

How can I send variables to Jinja template from a Flask decorator?

I’m going to propose something even simpler than using a decorator or template method or anything like that: def render_sidebar_template(tmpl_name, **kwargs): (var1, var2, var3) = generate_sidebar_data() return render_template(tmpl_name, var1=var1, var2=var2, var3=var3, **kwargs) Yup, just a function. That’s all you really need, isn’t it? See this Flask Snippet for inspiration. It’s essentially doing exactly the same … Read more

Why is partial class template argument deduction impossible?

From this excellent trip report by Botond Ballo: The feature as originally proposed included a provision for partial deduction, where you explicitly specify some of the template arguments, and leave the rest to be deduced, but this was pulled over concerns that it can be very confusing in some cases: // Would have deduced tuple<int, … Read more

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