Lifetime of lambda objects in relation to function pointer conversion

§5.1.2/6 says: The closure type for a lambda-expression with no lambda-capture has a public non-virtual non-explicit const conversion function to pointer to function having the same parameter and return types as the closure type’s function call operator. The value returned by this conversion function shall be the address of a function that, when invoked, has … Read more

Should std::bind be compatible with boost::asio?

I now have a solution The problem is that when I first tried to switch to std::bind and std::shared_ptr I was still using the boost::asio::placeholders with std::bind, this resulted in a large amount of template compiler errors, so I then tried to switch piecemeal. I first tried switching just boost::shared_ptr to std::shared_ptr, this failed because … Read more

std::unordered_map insert with hint

It is an interface compatibility issue. Basically, the design is done considering the interface of std::map. In other words, for std::unordered_map it does not differ a hint is provided or not. Additional Information from the comments here: The interface compatibility is very important because being able to quickly/easily switch between map and unordered_map provides the … Read more

using SFINAE for template class specialisation

IF the original declaration of User<> can be adapted to template<typename, typename=std::true_type> class User; then we can find a solution (following Luc Danton’s comment, instead of using std::enable_if) template<typename> struct is_Data : std::false_type {}; template<typename T> struct is_Data<Data<T>> : std::true_type {}; template<typename T> class User<T, typename is_Data<T>::type > { /* … */ }; However, this … Read more

Is it a conforming compiler extension to treat non-constexpr standard library functions as constexpr?

TL;DR In C++14 this is explicitly not allowed, although in 2011 it appeared like this case would be explicitly allowed. It is unclear if for C++11 this fell under the as-if rule, I don’t believe it does since it alters observable behavior but that point was not clarified in the issue I reference below. Details … Read more

What exactly is a ‘side-effect’ in C++?

A “side effect” is defined by the C++ standard in [intro.execution], by: Reading an object designated by a volatile glvalue (3.10), modifying an object, calling a library I/O function, or calling a function that does any of those operations are all side effects, which are changes in the state of the execution environment.