Skip to content

Instantly share code, notes, and snippets.

@tk-xleader
Created August 4, 2019 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tk-xleader/f84b6f81bb8988962b3651b420dd3651 to your computer and use it in GitHub Desktop.
Save tk-xleader/f84b6f81bb8988962b3651b420dd3651 to your computer and use it in GitHub Desktop.
// std::is_nothrow_convertible(added since C++2a) implementation in C++17.
namespace std{
namespace _details{
template<typename To>
std::void_t<To()> convert_to(To) noexcept;
template<typename From, typename To, typename = void>
struct is_nothrow_convertible_imp : std::false_type{};
template<typename From, typename To>
struct is_nothrow_convertible_imp<From, To, typename std::enable_if<noexcept(std::_details::convert_to<To>(std::declval<From>()))>::type> : std::true_type{};
}
template<typename From, typename To>
struct is_nothrow_convertible : std::conditional<
std::is_void<From>::value,
std::is_void<To>,
_details::is_nothrow_convertible_imp<From, To>
>::type{};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment