]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/function/cons/noexcept.cc
1 // { dg-do compile { target c++11 } }
2 // { dg-require-effective-target hosted }
13 using F
= std::function
<void(X
*)>;
15 static_assert( std::is_nothrow_constructible
<F
>::value
, "" );
16 static_assert( std::is_nothrow_constructible
<F
, F
>::value
, "" );
17 static_assert( ! std::is_nothrow_constructible
<F
, F
&>::value
, "" );
18 static_assert( ! std::is_nothrow_constructible
<F
, const F
&>::value
, "" );
19 static_assert( std::is_nothrow_constructible
<F
, std::nullptr_t
>::value
, "" );
21 static_assert( ! std::is_nothrow_constructible
<F
, X
>::value
, "" );
22 using R
= std::reference_wrapper
<X
>;
23 static_assert( std::is_nothrow_constructible
<F
, R
>::value
, "" );
26 // The standard requires that construction from a function pointer type
27 // does not throw, but doesn't require that the construction is noexcept.
28 // Strengthening that noexcept for these types is a GCC extension.
29 static_assert( std::is_nothrow_constructible
<F
, void(*)(X
*)>::value
, "" );
30 // This is a GCC extension, not required by the standard:
31 static_assert( std::is_nothrow_constructible
<F
, void(&)(X
*)>::value
, "" );
32 // This is a GCC extension, not required by the standard:
33 static_assert( std::is_nothrow_constructible
<F
, void(X::*)()>::value
, "" );
36 static_assert( std::is_nothrow_constructible
<F
, decltype(+c
)>::value
, "" );
37 // The standard allows this to throw, but as a GCC extenension we store
38 // closures with no captures in the std::function, so this is noexcept too:
39 static_assert( std::is_nothrow_constructible
<F
, decltype(c
)>::value
, "" );