Let's look at two examples:
struct A { A () noexcept = default; }; struct B : A { B () noexcept = default; template <typename T> B (T) noexcept {} }; struct C : A { using A::A; template <typename T> C (T) noexcept {} };
and use:
std::cout << std::is_nothrow_constructible<B>::value << std::endl; // (X) std::cout << std::is_nothrow_constructible<B, int>::value << std::endl; std::cout << std::is_nothrow_constructible<C>::value << std::endl; // (Y) std::cout << std::is_nothrow_constructible<C, int>::value << std::endl;
Output:
1 1 0 1
The compiler is used: GCC 4.8.1.
So, if I write explicitly the default constructor B , (X) creates 1, on the other hand, if the default constructor C is available due to inheritance, (Y) produces 0. Why is this?
Does this mean that inherited constructors are not taken into account when using the is_nothrow_constructible attribute?
source share