// Copyright (C) 2016-2022 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . // { dg-do compile { target c++11 } } // { dg-require-effective-target hosted } #include template struct resettable : std::false_type { }; template struct type_list { }; template using reset_result = decltype(std::shared_ptr{}.reset(std::declval()...)); template struct resettable, reset_result> : std::true_type { }; template constexpr bool can_reset() { return resettable>::value; } template struct Deleter { void operator()(T*) const; }; template using Alloc = std::allocator; struct Base { }; struct Derived : Base { }; // Positive cases: static_assert( can_reset(), "void* convertible to const void*"); static_assert( can_reset(), "int* convertible to const int*"); static_assert( can_reset(), "Derived* convertible to Base*"); static_assert( can_reset(), "Derived* convertible to const Base*"); // Negative cases: static_assert( !can_reset(), "void* not convertible to int*"); static_assert( !can_reset>(), "void* not convertible to int*"); static_assert( !can_reset, Alloc>(), "void* not convertible to int*"); static_assert( !can_reset(), "const int* not convertible to int*"); static_assert( !can_reset>(), "const int* not convertible to int*"); static_assert( !can_reset, Alloc>(), "const int* not convertible to int*"); static_assert( !can_reset(), "long* not convertible to int*"); static_assert( !can_reset>(), "long* not convertible to int*"); static_assert( !can_reset, Alloc>(), "long* not convertible to int*"); static_assert( !can_reset(), "Base* not convertible to Derived*"); static_assert( !can_reset>(), "Base* not convertible to Derived*"); static_assert( !can_reset, Alloc>(), "Base* not convertible to Derived*");