// { dg-do run { target c++14 } } // { dg-require-effective-target net_ts_ip } #include #include #include using namespace std; template void check_gettable_sockopt(P p, C c = C()) { static_assert( is_same().level(p)), int>(), "" ); static_assert( noexcept(declval().level(p)), "" ); static_assert( is_same().name(p)), int>(), "" ); static_assert( noexcept(declval().name(p)), "" ); static_assert( is_same().data(p)), void*>(), "" ); static_assert( noexcept(declval().data(p)), "" ); static_assert( is_same().size(p)), size_t>(), "" ); static_assert( noexcept(declval().size(p)), "" ); static_assert( is_same().resize(p, 0)), void>(), "" ); static_assert( ! noexcept(declval().resize(p, 0)), "" ); VERIFY(c.size(p) == sizeof(T)); } template void check_settable_sockopt(P p, C c = C()) { static_assert( is_same().level(p)), int>(), "" ); static_assert( noexcept(declval().level(p)), "" ); static_assert( is_same().name(p)), int>(), "" ); static_assert( noexcept(declval().name(p)), "" ); static_assert( is_same().data(p)), const void*>(), "" ); static_assert( noexcept(declval().data(p)), "" ); static_assert( is_same().size(p)), size_t>(), "" ); static_assert( noexcept(declval().size(p)), "" ); VERIFY(c.size(p) == sizeof(T)); } template void check_boolean_sockopt() { namespace ip = std::experimental::net::ip; #if __has_include() check_gettable_sockopt(ip::tcp::v4()); check_settable_sockopt(ip::tcp::v4()); #endif static_assert( is_destructible(), "" ); static_assert( is_nothrow_default_constructible(), "" ); static_assert( is_nothrow_copy_constructible(), "" ); static_assert( is_nothrow_copy_assignable(), "" ); static_assert( is_nothrow_constructible(), "" ); static_assert( is_nothrow_assignable(), "" ); static_assert( is_same().value()), bool>(), "" ); static_assert( noexcept(declval().value()), "" ); static_assert( is_same(declval())), bool>(), "" ); static_assert( noexcept(static_cast(declval())), "" ); static_assert( is_same()), bool>(), "" ); static_assert( noexcept(!declval()), "" ); } template void check_integer_sockopt() { namespace ip = std::experimental::net::ip; #if __has_include() check_gettable_sockopt(ip::tcp::v4()); check_settable_sockopt(ip::tcp::v4()); #endif static_assert( is_destructible(), "" ); static_assert( is_nothrow_default_constructible(), "" ); static_assert( is_nothrow_copy_constructible(), "" ); static_assert( is_nothrow_copy_assignable(), "" ); static_assert( is_nothrow_constructible(), "" ); static_assert( is_nothrow_assignable(), "" ); static_assert( is_same().value()), int>(), "" ); static_assert( noexcept(declval().value()), "" ); } template void check_mcast_sockopt(C& c) { namespace ip = std::experimental::net::ip; static_assert( is_destructible(), "" ); static_assert( is_copy_constructible(), "" ); static_assert( is_copy_assignable(), "" ); #if __has_include() check_settable_sockopt(ip::tcp::v6(), c); check_settable_sockopt(ip::tcp::v4(), c); #endif static_assert( is_nothrow_constructible(), "" ); static_assert( ! is_convertible(), "explicit" ); static_assert( is_nothrow_constructible(), "" ); static_assert( ! is_convertible(), "explicit" ); static_assert( is_nothrow_constructible(), "" ); static_assert( is_nothrow_constructible(), "" ); static_assert( ! is_convertible(), "explicit" ); static_assert( is_nothrow_constructible(), "" ); } void test_option_types() { namespace ip = std::experimental::net::ip; #if __has_include() #if __has_include() check_boolean_sockopt(); #endif check_boolean_sockopt(); check_integer_sockopt(); ip::multicast::join_group join(ip::address_v4::any()); check_mcast_sockopt(join); ip::multicast::leave_group leave(ip::address_v4::any()); check_mcast_sockopt(leave); using outbound_if = ip::multicast::outbound_interface; outbound_if oif(ip::address_v4::any()); check_settable_sockopt(ip::tcp::v6(), oif); check_settable_sockopt(ip::tcp::v4(), oif); static_assert( is_destructible(), "" ); static_assert( ! is_default_constructible(), "" ); static_assert( is_nothrow_copy_constructible(), "" ); static_assert( is_nothrow_copy_assignable(), "" ); static_assert( is_nothrow_constructible(), "" ); static_assert( ! is_convertible(), "explicit" ); static_assert( is_nothrow_constructible(), "" ); static_assert( ! is_convertible(), "explicit" ); check_integer_sockopt(); check_boolean_sockopt(); #endif } int main() { test_option_types(); }