Fix sir::is_custom

This commit is contained in:
Nikita Lisitsa 2023-08-15 11:47:43 +03:00
parent 67c7ce0878
commit 1036ebae30

View file

@ -5,12 +5,9 @@
#include <type_traits>
namespace psemek::sir
namespace psemek_sir_adl_helper
{
namespace detail
{
struct fake_istream
{
void read(char *, std::size_t){}
@ -25,8 +22,8 @@ namespace psemek::sir
std::size_t offset() const { return 0; }
};
static_assert(is_istream_v<fake_istream>);
static_assert(is_ostream_v<fake_ostream>);
static_assert(::psemek::sir::is_istream_v<fake_istream>);
static_assert(::psemek::sir::is_ostream_v<fake_ostream>);
template <typename T>
constexpr bool is_custom_helper = requires (T & x, fake_istream & is, fake_ostream & os)
@ -35,11 +32,14 @@ namespace psemek::sir
read(is, x);
};
}
}
namespace psemek::sir
{
template <typename T>
struct is_custom
: std::bool_constant<detail::is_custom_helper<T>>
: std::bool_constant<::psemek_sir_adl_helper::is_custom_helper<T>>
{};
template <typename T>
@ -55,7 +55,7 @@ namespace psemek::sir
template <typename T>
struct is_trivial
: std::bool_constant<std::is_trivial_v<T> && std::is_standard_layout_v<T>>
: std::bool_constant<std::is_trivially_default_constructible_v<T> && std::is_trivially_copyable_v<T> && std::is_standard_layout_v<T>>
{};
template <typename T>