Default destructor nothrow

The compilers are caught in a dilemma here, for the following reasons: (1) Not specifying any exceptions in a function declaration (i.e. not using throw nor noexcept (which is equivalent to noexcept(true) )) means to allow that function to throw all possible exceptions: (§15.4/12, emphasis mine) A function with no exception-specification or with an exception-specification … Read more

Detect existence of private member

There is indeed a way for non-final non-union class types: namespace detail { struct P {typedef int member;}; template <typename U> struct test_for_member : U, P { template <typename T=test_for_member, typename = typename T::member> static std::false_type test(int); static std::true_type test(float); }; } template <typename T> using test_for_member = std::integral_constant<bool, decltype(detail::test_for_member<T>::test(0)){}>; Demo. The trick is to … Read more

How are C++11 lambdas represented and passed?

Disclaimer: my answer is somewhat simplified compared to the reality (I put some details aside) but the big picture is here. Also, the Standard does not fully specify how lambdas or std::function must be implemented internally (the implementation has some freedom) so, like any discussion on implementation details, your compiler may or may not do … Read more

Move the string out of a std::ostringstream

This is now possible with C++20, with syntax like: const std::string s = std::move(ss).str(); This is possible because the std::ostringstream class now has a str() overload that is rvalue-ref qualified: basic_string<charT, traits, Allocator> str() &&; // since C++20 This was added in P0408, revision 7, which was adopted into C++20. This is the exact approach … 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

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