How to declare constexpr extern?

no you can’t do it, here’s what the standard says (section 7.1.5): 1 The constexpr specifier shall be applied only to the definition of a variable or variable template, the declaration of a function or function template, or the declaration of a static data member of a literal type (3.9). If any declaration of a … Read more

Will consteval functions allow template parameters dependent on function arguments?

No. Whatever changes the paper will entail, which is little at this point, it cannot change the fact that a non-template function definition is only typed once. Moreover, if your proposed code would be legal, we could presumably find a way to declare a variable of type std::integral_constant<int, i>, which feels very prohibitive in terms … Read more

Is it possible to declare constexpr class in a header and define it in a separate .cpp file?

If a constexpr function is not defined inside the header, the compiler can not see the definition of the constexpr functions while compiling all the other source files. Obviously, if it can’t see the definition of the functions, it can’t perform the steps necessary to calculate them at compile-time. Thus all constexpr functions must be … Read more

Computing length of a C string at compile time. Is this really a constexpr?

Constant expressions are not guaranteed to be evaluated at compile time, we only have a non-normative quote from draft C++ standard section 5.19 Constant expressions that says this though: […]>[ Note: Constant expressions can be evaluated during translation.—end note ] You can assign the result to constexpr variable to be sure it is evaluated at … Read more

Constexpr vs macros

Aren’t they basically the same? No. Absolutely not. Not even close. Apart from the fact your macro is an int and your constexpr unsigned is an unsigned, there are important differences and macros only have one advantage. Scope A macro is defined by the preprocessor and is simply substituted into the code every time it … Read more

Does constexpr imply inline?

Yes ([dcl.constexpr], §7.1.5/2 in the C++11 standard): “constexpr functions and constexpr constructors are implicitly inline (7.1.2).” Note, however, that the inline specifier really has very little (if any) effect upon whether a compiler is likely to expand a function inline or not. It does, however, affect the one definition rule, and from that perspective, the … Read more

Does static constexpr variable inside a function make sense?

The short answer is that not only is static useful, it is pretty well always going to be desired. First, note that static and constexpr are completely independent of each other. static defines the object’s lifetime during execution; constexpr specifies that the object should be available during compilation. Compilation and execution are disjoint and discontiguous, … Read more

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