“Default member initializer needed within definition of enclosing class outside of member functions” – is my code ill-formed?

Your code is fine from what I can tell. Clang seems to struggle with the = default constructor rather than just defining a default constructor manually. It has the following spiel in its source code about it: DR1351: If the brace-or-equal-initializer of a non-static data member invokes a defaulted default constructor of its class or … Read more

Given int **p1 and const int**p2 is p1 == p2 well formed?

Before C++14 this case was ill-formed and the more general case with some exceptions was also ill-formed. This is covered in defect report 1512: Pointer comparison vs qualification conversions , which says: According to 5.9 [expr.rel] paragraph 2, describing pointer comparisons, Pointer conversions (4.10 [conv.ptr]) and qualification conversions (4.4 [conv.qual]) are performed on pointer operands … Read more

Why is std::streamsize defined as signed rather than unsigned?

The draft C++ standard has the following footnote 296 in section 27.5.2 Types which says: streamsize is used in most places where ISO C would use size_t. Most of the uses of streamsize could use size_t, except for the strstreambuf constructors, which require negative values. It should probably be the signed type corresponding to size_t … Read more

Is writing to &str[0] buffer (of a std:string) well-defined behaviour in C++11?

Yes, the code is legal in C++11 because the storage for std::string is guaranteed to be contiguous and your code avoids overwriting the terminating NULL character (or value initialized CharT). From N3337, ยง21.4.5 [string.access] const_reference operator[](size_type pos) const; reference operator[](size_type pos); 1 Requires: pos <= size(). 2 Returns: *(begin() + pos) if pos < size(). … Read more

Access to constexpr variable inside lambda expression without capturing

Are there special rules that apply to constexpr for capturing/accessing? Yes, constexpr variables could be read without capturing in lambda: A lambda expression can read the value of a variable without capturing it if the variable has const non-volatile integral or enumeration type and has been initialized with a constant expression, or is constexpr and … Read more

Is std::any_of required to follow short circuit logic?

The standard itself doesn’t place any such hard requirement. But one may infer it is indirectly encouraged ([alg.any_of]): template <class InputIterator, class Predicate> bool any_of(InputIterator first, InputIterator last, Predicate pred); template <class ExecutionPolicy, class ForwardIterator, class Predicate> bool any_of(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Predicate pred); Returns: false if [first, last) is empty or if … Read more

Are functions calls in a constructor’s initializer-list sequenced?

So I am wondering if it is guaranteed that t.a == 0 and t.b == 1? This will always be true so long as a comes before b in the class declaration and nothing else calls f() between the initialization of a and b. Class members are initialized in the order they are declared in … Read more

C++ decltype and parentheses – why?

It’s not an oversight. It’s interesting, that in Decltype and auto (revision 4) (N1705=04-0145) there is a statement: The decltype rules now explicitly state that decltype((e)) == decltype(e)(as suggested by EWG). But in Decltype (revision 6): proposed wording (N2115=06-018) one of the changes is Parenthesized-expression inside decltype is not considered to be an id-expression. There … Read more

Why does not a template template parameter allow ‘typename’ after the parameter list

Short answer: because the Standard says so. Longer answer: prior to Standardization, C++ templates required the class keyword for all template parameters. However, to stress the fact that templates could also be of non-class (i.e. builtin) type, an alternative keyword typename was introduced. However, in C++98, template-template parameters could only be of class-type, and this … Read more

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