c++11 struct initialization compilation error

In C++11, when you use non static data member initialization at the point of declaration like you do here: struct SS {int a = 0; int s = 2;}; you make the class a non-aggregate. This means you can no longer initialize an instance like this: SS s{1,2}; To make this initialization syntax work for … Read more

Can we have a function with multiple return types? (in C++11 and above)

The return type must be determined at compile-time. You might use std::common_type (since C++11): For arithmetic types not subject to promotion, the common type may be viewed as the type of the (possibly mixed-mode) arithmetic expression such as T0() + T1() + … + Tn(). template < typename T, typename X> typename std::common_type<T, X>::type Max_Number … Read more

Why can I use operator= but not operator== with C++11 brace-initializers?

List-initialization cannot be used as an argument to an operator in the general case. Per Paragraph 8.5.4/1 of the C++11 Standard: […] List-initialization can be used — as the initializer in a variable definition (8.5) — as the initializer in a new expression (5.3.4) — in a return statement (6.6.3) — as a for-range-initializer (6.5) … Read more

std::is_constructible on incomplete types

The behavior is undefined. [meta.unary.prop] template <class T, class… Args> struct is_constructible; T and all types in the parameter pack Args shall be complete types, (possibly cv-qualified) void, or arrays of unknown bound. That’s a precondition of the meta-function. A contract that your code violates. libc++ is being generous by notifying you. Mind you, that … Read more

Why are there two overloads for vector::push_back?

I did this largely just because of how the situation evolved. Prior to C++11, there was only: vector<T>::push_back(const T&); With the introduction of rvalue references I recommended the addition of the overload: vector<T>::push_back(T&&); instead of changing the original signature to: template <class U> vector<T>::push_back(U&&); Part of this decision was made because of some concerns about … Read more

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