The following code triggers static_assert even though I don't think it should:
#include <type_traits>
template< typename T >
struct Tmp
{
~Tmp() noexcept( std::is_nothrow_destructible< T >::value ) {}
};
struct Foo;
struct Bar
{
// Comment this out for the problem to go away
Tmp< Foo > xx;
// ..or this
Bar() {}
};
struct Foo {};
// This triggers
static_assert( std::is_nothrow_destructible< Foo >::value, "That's odd" );
int main()
{
}
When compiled with:
g++-4.9 -std=c++11 nothrow_destructible_bug.cc
The following happens:
nothrow_destructible_bug.cc:20:1: error: static assertion failed: That's odd
static_assert( std::is_nothrow_destructible< Foo >::value, "That's odd" );
^
How come just using Foo to instantiate a template in an unrelated class make it lose its noexcept status? I thought this was a compiler bug, but I tried it with all recent versions of both gcc and clang and they all seem to give the same error.
Aucun commentaire:
Enregistrer un commentaire