What is C++20’s string literal operator template?

There were two separate proposals: Allowing string literals as non-type template parameters (P0424) Allowing class types as non-type template parameters (P0732) The first proposal was partially merged into the second. String literals still are not valid arguments as non-type template parameters, but they are valid arguments into class types. The example from [temp.arg.nontype]/4 might help: … Read more

Are C++14 digit separators allowed in user defined literals?

If you look at the grammar, user-defined-integer-literal can be octal-literal ud-suffix, and octal-literal is defined as either 0 or octal-literal ’opt octal-digit. N4140 §2.14.8 user-defined-literal: user-defined-integer-literal […] user-defined-integer-literal: octal-literal ud-suffix […] ​ N4140 §2.14.2 octal-literal: 0 octal-literal ’opt octal-digit So 01’23s is a perfectly valid literal.

What new capabilities do user-defined literals add to C++?

At first sight, it seems to be simple syntactic sugar. But when looking deeper, we see it’s more than syntactic sugar, as it extends the C++ user’s options to create user-defined types that behave exactly like distinct built-in types. In this, this little “bonus” is a very interesting C++11 addition to C++. Do we really … Read more

Conveniently Declaring Compile-Time Strings in C++

I haven’t seen anything to match the elegance of Scott Schurr’s str_const presented at C++ Now 2012. It does require constexpr though. Here’s how you can use it, and what it can do: int main() { constexpr str_const my_string = “Hello, world!”; static_assert(my_string.size() == 13, “”); static_assert(my_string[4] == ‘o’, “”); constexpr str_const my_other_string = my_string; … Read more

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