What are the differences between C-like, constructor, and uniform initialization?

First, I would recommend looking at the following talk by Herb Sutter, in which he gives some recommendations about the subject. The brace-initialization discussion starts at around 23:00. When you are talking about primitive data types, all 3 yield the same result. I personally prefer sticking with the old int x = 0 syntax, but … Read more

How can I pass a class member function as a callback?

This is a simple question but the answer is surprisingly complex. The short answer is you can do what you’re trying to do with std::bind1st or boost::bind. The longer answer is below. The compiler is correct to suggest you use &CLoggersInfra::RedundencyManagerCallBack. First, if RedundencyManagerCallBack is a member function, the function itself doesn’t belong to any … Read more

Default, value and zero initialization mess

C++14 specifies initialization of objects created with new in [expr.new]/17 ([expr.new]/15 in C++11, and the note wasn’t a note but normative text back then): A new-expression that creates an object of type T initializes that object as follows: If the new-initializer is omitted, the object is default-initialized (8.5). [ Note: If no initialization is performed, … Read more

What differences, if any, between C++03 and C++11 can be detected at run-time?

Core Language Accessing an enumerator using ::: template<int> struct int_ { }; template<typename T> bool isCpp0xImpl(int_<T::X>*) { return true; } template<typename T> bool isCpp0xImpl(…) { return false; } enum A { X }; bool isCpp0x() { return isCpp0xImpl<A>(0); } You can also abuse the new keywords struct a { }; struct b { a a1, … Read more

Purpose of Trigraph sequences in C++?

This question (about the closely related digraphs) has the answer. It boils down to the fact that the ISO 646 character set doesn’t have all the characters of the C syntax, so there are some systems with keyboards and displays that can’t deal with the characters (though I imagine that these are quite rare nowadays). … Read more

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