Must template argument functions be treated as potentially constexpr?

Introduction template<int F(), int N = F()> void func (); In this answer we will go through the relevant sections of the International Standard, step by step, to prove that the above snippet is well-formed. What does the International Standard (N3337) say? The Standardese 14.1p9 Template parameters [temp.param] A default template-argument is a template-argument (14.3) … Read more

Is it legal to declare a constexpr initializer_list object?

Update: The situation got a bit more complicated after the resolution of CWG DR 1684 removed the requirement quoted below. Some more information can be found in this discussion on the std-discussion mailing list and in the related question Why isn’t `std::initializer_list` defined as a literal type? [decl.constexpr]/8: A constexpr specifier for a non-static member … Read more

Where in the standard are functions returning functions disallowed?

From [dcl.fct], pretty explicitly: Functions shall not have a return type of type array or function, although they may have a return type of type pointer or reference to such things. There shall be no arrays of functions, although there can be arrays of pointers to functions. With C++11, you probably just want: std::function<int()> f(); … Read more

What is the correct output of sizeof(“string”)?

This is all 100% standardized. C17 6.10.8.1: __DATE__ The date of translation of the preprocessing translation unit: a character string literal of the form “Mmm dd yyyy” … and the first character of dd is a space character if the value is less than 10. … __TIME__ The time of translation of the preprocessing translation … Read more

What is the order of evaluation of assignment operators?

Order of Left and Right Operands To perform the assignment in arr[global_var] = update_three(2), the C implementation must evaluate the operands and, as a side effect, update the stored value of the left operand. C 2018 6.5.16 (which is about assignments) paragraph 3 tells us there is no sequencing in the left and right operands: … Read more

Does a pointer to std::byte have the same aliasing relaxations as char*?

From the current Standard draft ([basic.types.general]/2): For any object (other than a potentially-overlapping subobject) of trivially copyable type T, whether or not the object holds a valid value of type T, the underlying bytes ([intro.memory]) making up the object can be copied into an array of char, unsigned char, or std​::​byte ([cstddef.syn]). If the content … Read more

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