- The banning of narrowing conversions during aggregate initialization in C++11
int a[] = { 1.0 }; // invalid C++ 11
>>
on the right of template parameter is valid in C++11 but not in C++03std::swap
are defined in<utility>
in C++11 but<algorithm>
in C++98.std::basic_ios
has in C++11explicit operator bool() const
instead of a conversion that evaluates tobool
.- string literals do not convert to
char*
in C++11.
- Integer division always rounds to zero.
- a destructor is now by default
noexcept(true)
unless specified otherwise, but C++98 allows exceptions. - Dependent function calls with internal linkage are considered in C++11
static void f(int) { } void f(long) { } template<typename T> void g(T t) { f(t); } int main() { g(0); } // caslls f(int) in C++11 but f(long) in C++98 // However, with instantiation, this still calls f(B) struct B { }; struct A : B { }; template<typename T> void g(T t) { f(t); } static void f(A) { } void f(B) { } int main() { A a; g(a); }
std::vector<T> a(50)
resolves to a separate constructor that construct the elements in place in C++11 while in C++03 a default value of the second parameter is copied to each slot.- in case where a copy constructor taking a default value is different from the default constructor, this behavior is a breaking change.
- C++17 changed
std::string::data
tochar*
fromconst char*
to allow easy in-place string data modification through a pointer. - Unnamed classes with a
typedef
name for linkage purposes (i.e. C++ code) can contain only
C-compatible constructs since C++20. Note this does not forbid the use inside
extern "C"
blocks or structs that contains only data.
// forbidden since C++20
typedef struct {
void member_function();
} m_struct;