A bunch of cleanup
This commit is contained in:
@ -11,3 +11,7 @@
|
||||
#define ASL_ASSERT(...) \
|
||||
if (__VA_ARGS__) {} \
|
||||
else { ASL_DEBUG_BREAK(); }
|
||||
|
||||
#define ASL_ASSERT_RELEASE(...) \
|
||||
if (__VA_ARGS__) {} \
|
||||
else { ASL_DEBUG_BREAK(); }
|
||||
|
39
asl/meta.hpp
39
asl/meta.hpp
@ -24,7 +24,7 @@ template<bool kSelect, typename U, typename V> using select_t = _select_helper<k
|
||||
template<typename U, typename V> struct _is_same_helper : false_type {};
|
||||
template<typename T> struct _is_same_helper<T, T> : true_type {};
|
||||
|
||||
template<typename U, typename V> concept is_same = _is_same_helper<U, V>::value && _is_same_helper<V, U>::value;
|
||||
template<typename U, typename V> concept same_as = _is_same_helper<U, V>::value && _is_same_helper<V, U>::value;
|
||||
|
||||
template<typename T> auto _as_lref_helper(int) -> id<T&>;
|
||||
template<typename T> auto _as_lref_helper(...) -> id<T>;
|
||||
@ -43,38 +43,37 @@ template<typename T> struct _un_ref_t<T&&> { using type = T; };
|
||||
|
||||
template<typename T> using un_ref_t = _un_ref_t<T>::type;
|
||||
|
||||
template<typename T, typename... Args> concept constructible = __is_constructible(T, Args...);
|
||||
template<typename T, typename... Args> concept constructible_from = __is_constructible(T, Args...);
|
||||
|
||||
template<typename T> concept default_constructible = constructible<T>;
|
||||
template<typename T> concept copy_constructible = constructible<T, as_lref_t<const T>>;
|
||||
template<typename T> concept move_constructible = constructible<T, as_rref_t<T>>;
|
||||
template<typename T> concept default_constructible = constructible_from<T>;
|
||||
template<typename T> concept copy_constructible = constructible_from<T, as_lref_t<const T>>;
|
||||
template<typename T> concept move_constructible = constructible_from<T, as_rref_t<T>>;
|
||||
|
||||
template<typename T, typename... Args> concept trivially_constructible = __is_trivially_constructible(T, Args...);
|
||||
template<typename T, typename... Args> concept trivially_constructible_from = __is_trivially_constructible(T, Args...);
|
||||
|
||||
template<typename T> concept trivially_default_constructible = trivially_constructible<T>;
|
||||
template<typename T> concept trivially_copy_constructible = trivially_constructible<T, as_lref_t<const T>>;
|
||||
template<typename T> concept trivially_move_constructible = trivially_constructible<T, as_rref_t<T>>;
|
||||
template<typename T> concept trivially_default_constructible = trivially_constructible_from<T>;
|
||||
template<typename T> concept trivially_copy_constructible = trivially_constructible_from<T, as_lref_t<const T>>;
|
||||
template<typename T> concept trivially_move_constructible = trivially_constructible_from<T, as_rref_t<T>>;
|
||||
|
||||
template<typename T, typename... Args> concept assignable = __is_assignable(T, Args...);
|
||||
template<typename T, typename... Args> concept assignable_from = __is_assignable(T, Args...);
|
||||
|
||||
template<typename T> concept copy_assignable = assignable<as_lref_t<T>, as_lref_t<const T>>;
|
||||
template<typename T> concept move_assignable = assignable<as_lref_t<T>, as_rref_t<T>>;
|
||||
template<typename T> concept copy_assignable = assignable_from<as_lref_t<T>, as_lref_t<const T>>;
|
||||
template<typename T> concept move_assignable = assignable_from<as_lref_t<T>, as_rref_t<T>>;
|
||||
|
||||
template<typename T, typename... Args> concept trivially_assignable = __is_trivially_assignable(T, Args...);
|
||||
template<typename T, typename... Args> concept trivially_assignable_from = __is_trivially_assignable(T, Args...);
|
||||
|
||||
template<typename T> concept trivially_copy_assignable = trivially_assignable<as_lref_t<T>, as_lref_t<const T>>;
|
||||
template<typename T> concept trivially_move_assignable = trivially_assignable<as_lref_t<T>, as_rref_t<T>>;
|
||||
template<typename T> concept trivially_copy_assignable = trivially_assignable_from<as_lref_t<T>, as_lref_t<const T>>;
|
||||
template<typename T> concept trivially_move_assignable = trivially_assignable_from<as_lref_t<T>, as_rref_t<T>>;
|
||||
|
||||
template<typename T> concept trivially_destructible = __is_trivially_destructible(T);
|
||||
|
||||
template<typename T> concept trivially_copyable = __is_trivially_copyable(T);
|
||||
|
||||
// @Todo Rename concepts (_from)
|
||||
template<typename From, typename To>
|
||||
concept convertible = __is_convertible(From, To);
|
||||
template<typename To, typename From>
|
||||
concept convertible_from = __is_convertible(From, To);
|
||||
|
||||
template<typename Derived, class Base>
|
||||
concept derived_from = __is_class(Derived) && __is_class(Base) && convertible<const volatile Derived*, const volatile Base*>;
|
||||
concept derived_from = __is_class(Derived) && __is_class(Base) && convertible_from<const volatile Base*, const volatile Derived*>;
|
||||
|
||||
using nullptr_t = decltype(nullptr);
|
||||
|
||||
@ -92,7 +91,7 @@ template<typename T> using un_cv_t = un_volatile_t<un_const_t<T>>;
|
||||
|
||||
template<typename T> using un_cvref_t = un_ref_t<un_cv_t<T>>;
|
||||
|
||||
template<typename T> concept is_void = is_same<void, un_cv_t<T>>;
|
||||
template<typename T> concept is_void = same_as<void, un_cv_t<T>>;
|
||||
|
||||
template<typename T> struct _is_ref_helper { static constexpr bool l = false; static constexpr bool r = false; };
|
||||
template<typename T> struct _is_ref_helper<T&> { static constexpr bool l = true; static constexpr bool r = false; };
|
||||
|
@ -23,24 +23,24 @@ namespace option_internal
|
||||
|
||||
template<typename T, typename U>
|
||||
concept convertible_from_option =
|
||||
convertible<option<U>&, T> &&
|
||||
convertible<const option<U>&, T> &&
|
||||
convertible<option<U>&&, T> &&
|
||||
convertible<const option<U>&&, T>;
|
||||
convertible_from<T, option<U>&> &&
|
||||
convertible_from<T, const option<U>&> &&
|
||||
convertible_from<T, option<U>&&> &&
|
||||
convertible_from<T, const option<U>&&>;
|
||||
|
||||
template<typename T, typename U>
|
||||
concept constructible_from_option =
|
||||
constructible<T, option<U>&> &&
|
||||
constructible<T, const option<U>&> &&
|
||||
constructible<T, option<U>&&> &&
|
||||
constructible<T, const option<U>&&>;
|
||||
constructible_from<T, option<U>&> &&
|
||||
constructible_from<T, const option<U>&> &&
|
||||
constructible_from<T, option<U>&&> &&
|
||||
constructible_from<T, const option<U>&&>;
|
||||
|
||||
template<typename T, typename U>
|
||||
concept assignable_from_option =
|
||||
assignable<T&, option<U>&> &&
|
||||
assignable<T&, const option<U>&> &&
|
||||
assignable<T&, option<U>&&> &&
|
||||
assignable<T&, const option<U>&&>;
|
||||
assignable_from<T&, option<U>&> &&
|
||||
assignable_from<T&, const option<U>&> &&
|
||||
assignable_from<T&, option<U>&&> &&
|
||||
assignable_from<T&, const option<U>&&>;
|
||||
|
||||
template<typename T, typename U>
|
||||
concept convertible_constructible_from_option =
|
||||
@ -57,7 +57,7 @@ template<typename T>
|
||||
concept is_option = requires
|
||||
{
|
||||
typename T::type;
|
||||
requires is_same<un_cvref_t<T>, option<typename T::type>>;
|
||||
requires same_as<un_cvref_t<T>, option<typename T::type>>;
|
||||
};
|
||||
|
||||
template<is_object T>
|
||||
@ -112,11 +112,11 @@ public:
|
||||
constexpr option(nullopt_t) {} // NOLINT(*-explicit-conversions)
|
||||
|
||||
template<typename U = T>
|
||||
constexpr explicit (!convertible<U&&, T>)
|
||||
constexpr explicit (!convertible_from<T, U&&>)
|
||||
option(U&& value)
|
||||
requires (
|
||||
constructible<T, U> &&
|
||||
!is_same<un_cvref_t<U>, option>
|
||||
constructible_from<T, U> &&
|
||||
!same_as<un_cvref_t<U>, option>
|
||||
)
|
||||
{
|
||||
construct(ASL_FWD(value));
|
||||
@ -150,10 +150,10 @@ public:
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
constexpr explicit (!convertible<const U&, T>)
|
||||
constexpr explicit (!convertible_from<T, const U&>)
|
||||
option(const option<U>& other)
|
||||
requires (
|
||||
constructible<T, const U&> &&
|
||||
constructible_from<T, const U&> &&
|
||||
!option_internal::convertible_constructible_from_option<T, U>
|
||||
)
|
||||
{
|
||||
@ -164,10 +164,10 @@ public:
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
constexpr explicit (!convertible<U&&, T>)
|
||||
constexpr explicit (!convertible_from<T, U&&>)
|
||||
option(option<U>&& other)
|
||||
requires (
|
||||
constructible<T, U&&> &&
|
||||
constructible_from<T, U&&> &&
|
||||
!option_internal::convertible_constructible_from_option<T, U>
|
||||
)
|
||||
{
|
||||
@ -186,9 +186,9 @@ public:
|
||||
template<typename U = T>
|
||||
constexpr option& operator=(U&& value) &
|
||||
requires (
|
||||
assignable<T&, U> &&
|
||||
constructible<T, U> &&
|
||||
!is_same<un_cvref_t<U>, option>
|
||||
assignable_from<T&, U> &&
|
||||
constructible_from<T, U> &&
|
||||
!same_as<un_cvref_t<U>, option>
|
||||
)
|
||||
{
|
||||
if (m_has_value)
|
||||
@ -263,8 +263,8 @@ public:
|
||||
template<typename U = T>
|
||||
constexpr option& operator=(const option<U>& other) &
|
||||
requires (
|
||||
constructible<T, const U&> &&
|
||||
assignable<T&, const U&> &&
|
||||
constructible_from<T, const U&> &&
|
||||
assignable_from<T&, const U&> &&
|
||||
!option_internal::convertible_constructible_assignable_from_option<T, U>
|
||||
)
|
||||
{
|
||||
@ -290,8 +290,8 @@ public:
|
||||
template<typename U = T>
|
||||
constexpr option& operator=(option<U>&& other) &
|
||||
requires (
|
||||
constructible<T, U> &&
|
||||
assignable<T&, U> &&
|
||||
constructible_from<T, U> &&
|
||||
assignable_from<T&, U> &&
|
||||
!option_internal::convertible_constructible_assignable_from_option<T, U>
|
||||
)
|
||||
{
|
||||
@ -337,7 +337,7 @@ public:
|
||||
|
||||
constexpr T&& value() &&
|
||||
{
|
||||
ASL_ASSERT(m_has_value); // @Todo Release assert
|
||||
ASL_ASSERT_RELEASE(m_has_value);
|
||||
if constexpr (kIsTrivial)
|
||||
{
|
||||
return ASL_MOVE(m_payload);
|
||||
@ -350,7 +350,7 @@ public:
|
||||
|
||||
constexpr T& value() &
|
||||
{
|
||||
ASL_ASSERT(m_has_value); // @Todo Release assert
|
||||
ASL_ASSERT_RELEASE(m_has_value);
|
||||
if constexpr (kIsTrivial)
|
||||
{
|
||||
return m_payload;
|
||||
@ -363,7 +363,7 @@ public:
|
||||
|
||||
constexpr const T& value() const&
|
||||
{
|
||||
ASL_ASSERT(m_has_value); // @Todo Release assert
|
||||
ASL_ASSERT_RELEASE(m_has_value);
|
||||
if constexpr (kIsTrivial)
|
||||
{
|
||||
return m_payload;
|
||||
@ -376,21 +376,21 @@ public:
|
||||
|
||||
template<typename U>
|
||||
constexpr T value_or(U&& other_value) const&
|
||||
requires copy_constructible<T> && convertible<U&&, T>
|
||||
requires copy_constructible<T> && convertible_from<T, U&&>
|
||||
{
|
||||
return has_value() ? value() : static_cast<T>(ASL_FWD(other_value));
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
constexpr T value_or(U&& other_value) &&
|
||||
requires move_constructible<T> && convertible<U&&, T>
|
||||
requires move_constructible<T> && convertible_from<T, U&&>
|
||||
{
|
||||
return has_value() ? ASL_MOVE(value()) : static_cast<T>(ASL_FWD(other_value));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
constexpr T& emplace(Args&&... args) &
|
||||
requires constructible<T, Args&&...>
|
||||
requires constructible_from<T, Args&&...>
|
||||
{
|
||||
if (m_has_value) { reset(); }
|
||||
construct(ASL_FWD(args)...);
|
||||
@ -465,14 +465,14 @@ public:
|
||||
|
||||
template<typename F>
|
||||
constexpr option or_else(F&& f) const&
|
||||
requires is_same<un_cvref_t<result_of_t<F()>>, option>
|
||||
requires same_as<un_cvref_t<result_of_t<F()>>, option>
|
||||
{
|
||||
return has_value() ? *this : invoke(ASL_FWD(f));
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
constexpr option or_else(F&& f) &&
|
||||
requires is_same<un_cvref_t<result_of_t<F()>>, option>
|
||||
requires same_as<un_cvref_t<result_of_t<F()>>, option>
|
||||
{
|
||||
return has_value() ? ASL_MOVE(*this) : invoke(ASL_FWD(f));
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
ASL_TEST(Format)
|
||||
ASL_TEST(format_args)
|
||||
{
|
||||
StringSink sink;
|
||||
|
||||
@ -79,6 +79,11 @@ ASL_TEST(Format)
|
||||
sink.reset();
|
||||
asl::format(&sink, "{{{}}} }", "CHEESE");
|
||||
ASL_TEST_ASSERT(strcmp(sink.cstr(), "{CHEESE} }") == 0);
|
||||
}
|
||||
|
||||
ASL_TEST(format_integers)
|
||||
{
|
||||
StringSink sink;
|
||||
|
||||
sink.reset();
|
||||
asl::format(&sink, "{} {} {}", 0, 1, 2);
|
||||
@ -99,6 +104,11 @@ ASL_TEST(Format)
|
||||
sink.reset();
|
||||
asl::format(&sink, "{} {} {} {}", -1, -23, -456, -7890);
|
||||
ASL_TEST_ASSERT(strcmp(sink.cstr(), "-1 -23 -456 -7890") == 0);
|
||||
}
|
||||
|
||||
ASL_TEST(format_boolean)
|
||||
{
|
||||
StringSink sink;
|
||||
|
||||
sink.reset();
|
||||
asl::format(&sink, "{} {}", true, false);
|
||||
|
@ -21,14 +21,14 @@ struct Functor
|
||||
|
||||
static int some_func0() { return 1; }
|
||||
static int some_func1(int x) { return x + 1; }
|
||||
static float some_func1(float x) { return x + 1; }
|
||||
[[maybe_unused]] static float some_func1(float x) { return x + 1; }
|
||||
static int some_func2(int x, int b) { return x + b; }
|
||||
|
||||
static_assert(asl::is_same<asl::result_of_t<Functor()>, int64_t>);
|
||||
static_assert(asl::is_same<asl::result_of_t<Functor(int)>, int>);
|
||||
static_assert(asl::is_same<asl::result_of_t<decltype(static_cast<float(*)(float)>(some_func1))(float)>, float>);
|
||||
static_assert(asl::is_same<asl::result_of_t<decltype(&HasFunction::do_something)(HasFunction, int, float)>, void>);
|
||||
static_assert(asl::is_same<asl::result_of_t<decltype(&HasMember::member)(HasMember)>, int>);
|
||||
static_assert(asl::same_as<asl::result_of_t<Functor()>, int64_t>);
|
||||
static_assert(asl::same_as<asl::result_of_t<Functor(int)>, int>);
|
||||
static_assert(asl::same_as<asl::result_of_t<decltype(static_cast<float(*)(float)>(some_func1))(float)>, float>);
|
||||
static_assert(asl::same_as<asl::result_of_t<decltype(&HasFunction::do_something)(HasFunction, int, float)>, void>);
|
||||
static_assert(asl::same_as<asl::result_of_t<decltype(&HasMember::member)(HasMember)>, int>);
|
||||
|
||||
ASL_TEST(invoke_member_function)
|
||||
{
|
||||
|
@ -1,17 +1,16 @@
|
||||
#include "asl/meta.hpp"
|
||||
#include "asl/tests/test_types.hpp"
|
||||
#include "asl/testing/testing.hpp"
|
||||
|
||||
struct Struct {};
|
||||
union Union {};
|
||||
enum Enum { EnumVariant = 0, };
|
||||
enum class EnumClass { Variant = 0, };
|
||||
enum Enum : uint8_t { EnumVariant = 0, };
|
||||
enum class EnumClass : uint8_t { Variant = 0, };
|
||||
|
||||
static_assert(!asl::is_same<long, short>);
|
||||
static_assert(asl::is_same<int, int>);
|
||||
static_assert(!asl::same_as<long, short>);
|
||||
static_assert(asl::same_as<int, int>);
|
||||
|
||||
static_assert(asl::is_same<asl::select_t<false, int, float>, float>);
|
||||
static_assert(asl::is_same<asl::select_t<true, int, float>, int>);
|
||||
static_assert(asl::same_as<asl::select_t<false, int, float>, float>);
|
||||
static_assert(asl::same_as<asl::select_t<true, int, float>, int>);
|
||||
|
||||
static_assert(asl::default_constructible<int>);
|
||||
static_assert(asl::default_constructible<TriviallyDefaultConstructible>);
|
||||
@ -67,18 +66,18 @@ static_assert(asl::trivially_destructible<int>);
|
||||
static_assert(asl::trivially_destructible<TriviallyDestructible>);
|
||||
static_assert(!asl::trivially_destructible<HasDestructor>);
|
||||
|
||||
static_assert(asl::is_same<int, asl::un_const_t<int>>);
|
||||
static_assert(asl::is_same<int, asl::un_const_t<const int>>);
|
||||
static_assert(asl::is_same<const int&, asl::un_const_t<const int&>>);
|
||||
static_assert(asl::same_as<int, asl::un_const_t<int>>);
|
||||
static_assert(asl::same_as<int, asl::un_const_t<const int>>);
|
||||
static_assert(asl::same_as<const int&, asl::un_const_t<const int&>>);
|
||||
|
||||
static_assert(asl::is_same<int, asl::un_volatile_t<int>>);
|
||||
static_assert(asl::is_same<int, asl::un_volatile_t<volatile int>>);
|
||||
static_assert(asl::is_same<volatile int&, asl::un_volatile_t<volatile int&>>);
|
||||
static_assert(asl::same_as<int, asl::un_volatile_t<int>>);
|
||||
static_assert(asl::same_as<int, asl::un_volatile_t<volatile int>>);
|
||||
static_assert(asl::same_as<volatile int&, asl::un_volatile_t<volatile int&>>);
|
||||
|
||||
static_assert(asl::is_same<int, asl::un_cv_t<int>>);
|
||||
static_assert(asl::is_same<int, asl::un_cv_t<const int>>);
|
||||
static_assert(asl::is_same<int, asl::un_cv_t<const volatile int>>);
|
||||
static_assert(asl::is_same<int, asl::un_cv_t<volatile int>>);
|
||||
static_assert(asl::same_as<int, asl::un_cv_t<int>>);
|
||||
static_assert(asl::same_as<int, asl::un_cv_t<const int>>);
|
||||
static_assert(asl::same_as<int, asl::un_cv_t<const volatile int>>);
|
||||
static_assert(asl::same_as<int, asl::un_cv_t<volatile int>>);
|
||||
|
||||
static_assert(asl::is_void<void>);
|
||||
static_assert(asl::is_void<const void>);
|
||||
@ -108,14 +107,14 @@ static_assert(!asl::is_ptr<void>);
|
||||
static_assert(!asl::is_ptr<void()>);
|
||||
static_assert(!asl::is_ptr<void() const &&>);
|
||||
|
||||
static_assert(asl::is_same<int, asl::tame_t<int>>);
|
||||
static_assert(asl::is_same<int(), asl::tame_t<int()>>);
|
||||
static_assert(asl::is_same<int(float), asl::tame_t<int(float)>>);
|
||||
static_assert(asl::is_same<int(float), asl::tame_t<int(float) &>>);
|
||||
static_assert(asl::is_same<int(float), asl::tame_t<int(float) const &&>>);
|
||||
static_assert(asl::is_same<int(float), asl::tame_t<int(float) volatile noexcept>>);
|
||||
static_assert(asl::is_same<int(float), asl::tame_t<int(float) && noexcept>>);
|
||||
static_assert(asl::is_same<int(float), asl::tame_t<int(float) const>>);
|
||||
static_assert(asl::same_as<int, asl::tame_t<int>>);
|
||||
static_assert(asl::same_as<int(), asl::tame_t<int()>>);
|
||||
static_assert(asl::same_as<int(float), asl::tame_t<int(float)>>);
|
||||
static_assert(asl::same_as<int(float), asl::tame_t<int(float) &>>);
|
||||
static_assert(asl::same_as<int(float), asl::tame_t<int(float) const &&>>);
|
||||
static_assert(asl::same_as<int(float), asl::tame_t<int(float) volatile noexcept>>);
|
||||
static_assert(asl::same_as<int(float), asl::tame_t<int(float) && noexcept>>);
|
||||
static_assert(asl::same_as<int(float), asl::tame_t<int(float) const>>);
|
||||
|
||||
static_assert(asl::is_func<void()>);
|
||||
static_assert(asl::is_func<void(int)>);
|
||||
@ -154,10 +153,10 @@ static_assert(!asl::is_array<void>);
|
||||
static_assert(!asl::is_array<void(int)>);
|
||||
static_assert(!asl::is_array<int(float) const && noexcept>);
|
||||
|
||||
static_assert(asl::is_same<int, asl::un_ref_t<int>>);
|
||||
static_assert(asl::is_same<int, asl::un_ref_t<int&>>);
|
||||
static_assert(asl::is_same<int, asl::un_ref_t<int&&>>);
|
||||
static_assert(asl::is_same<int() &, asl::un_ref_t<int() &>>);
|
||||
static_assert(asl::same_as<int, asl::un_ref_t<int>>);
|
||||
static_assert(asl::same_as<int, asl::un_ref_t<int&>>);
|
||||
static_assert(asl::same_as<int, asl::un_ref_t<int&&>>);
|
||||
static_assert(asl::same_as<int() &, asl::un_ref_t<int() &>>);
|
||||
|
||||
static_assert(asl::types_count<int, float> == 2);
|
||||
static_assert(asl::types_count<int, int> == 2);
|
||||
@ -173,14 +172,14 @@ static_assert(asl::trivially_copyable<TriviallyDefaultConstructible>);
|
||||
class Base {};
|
||||
class Derived : public Base {};
|
||||
class C {};
|
||||
class D { public: operator C() { return c; } C c; };
|
||||
class E { public: template<class T> E(T&&) {} };
|
||||
class D { public: operator C() { return c; } C c; }; // NOLINT
|
||||
class E { public: template<class T> E(T&&) {} }; // NOLINT
|
||||
|
||||
static_assert(asl::convertible<Derived*, Base*>);
|
||||
static_assert(!asl::convertible<Base*, Derived*>);
|
||||
static_assert(asl::convertible<D, C>);
|
||||
static_assert(!asl::convertible<Derived*, C*>);
|
||||
static_assert(asl::convertible<Base, E>);
|
||||
static_assert(asl::convertible_from<Base*, Derived*>);
|
||||
static_assert(!asl::convertible_from<Derived*, Base*>);
|
||||
static_assert(asl::convertible_from<C, D>);
|
||||
static_assert(!asl::convertible_from<C*, Derived*>);
|
||||
static_assert(asl::convertible_from<E, Base>);
|
||||
|
||||
static_assert(asl::derived_from<Derived, Base>);
|
||||
static_assert(!asl::derived_from<Base, Derived>);
|
||||
|
@ -32,23 +32,23 @@ static_assert(asl::move_assignable<asl::option<CopyAssignable>>);
|
||||
static_assert(asl::move_assignable<asl::option<MoveAssignable>>);
|
||||
static_assert(!asl::move_assignable<asl::option<NonMoveAssignable>>);
|
||||
|
||||
static_assert(asl::assignable<asl::option<Base*>&, asl::option<Derived*>>);
|
||||
static_assert(!asl::assignable<asl::option<Derived*>&, asl::option<Base*>>);
|
||||
static_assert(asl::assignable_from<asl::option<Base*>&, asl::option<Derived*>>);
|
||||
static_assert(!asl::assignable_from<asl::option<Derived*>&, asl::option<Base*>>);
|
||||
|
||||
static_assert(!asl::convertible<asl::option<Base*>, asl::option<Derived*>>);
|
||||
static_assert(asl::convertible<asl::option<Derived*>, asl::option<Base*>>);
|
||||
static_assert(asl::convertible_from<asl::option<Base*>, asl::option<Derived*>>);
|
||||
static_assert(!asl::convertible_from<asl::option<Derived*>, asl::option<Base*>>);
|
||||
|
||||
class ExplicitConversion { public: explicit ExplicitConversion(int) {} };
|
||||
class ImplicitConversion { public: ImplicitConversion(int) {} }; // NOLINT
|
||||
|
||||
static_assert(!asl::convertible<int, ExplicitConversion>);
|
||||
static_assert(asl::convertible<int, ImplicitConversion>);
|
||||
static_assert(!asl::convertible_from<ExplicitConversion, int>);
|
||||
static_assert(asl::convertible_from<ImplicitConversion, int>);
|
||||
|
||||
static_assert(!asl::convertible<int, asl::option<ExplicitConversion>>);
|
||||
static_assert(asl::convertible<int, asl::option<ImplicitConversion>>);
|
||||
static_assert(!asl::convertible_from<asl::option<ExplicitConversion>, int>);
|
||||
static_assert(asl::convertible_from<asl::option<ImplicitConversion>, int>);
|
||||
|
||||
static_assert(!asl::convertible<asl::option<int>, asl::option<ExplicitConversion>>);
|
||||
static_assert(asl::convertible<asl::option<int>, asl::option<ImplicitConversion>>);
|
||||
static_assert(!asl::convertible_from<asl::option<ExplicitConversion>, asl::option<int>>);
|
||||
static_assert(asl::convertible_from<asl::option<ImplicitConversion>, asl::option<int>>);
|
||||
|
||||
static_assert(asl::trivially_copy_constructible<asl::option<int>>);
|
||||
static_assert(!asl::trivially_copy_constructible<asl::option<CopyConstructible>>);
|
||||
@ -233,12 +233,12 @@ ASL_TEST(and_then)
|
||||
auto fn = [](int x) -> asl::option<float> { return static_cast<float>(x) + 0.5F; };
|
||||
|
||||
auto a2 = a.and_then(fn);
|
||||
static_assert(asl::is_same<decltype(a2), asl::option<float>>);
|
||||
static_assert(asl::same_as<decltype(a2), asl::option<float>>);
|
||||
ASL_TEST_ASSERT(a2.has_value());
|
||||
ASL_TEST_EXPECT(a2.value() == 5.5F);
|
||||
|
||||
auto b2 = b.and_then(fn);
|
||||
static_assert(asl::is_same<decltype(b2), asl::option<float>>);
|
||||
static_assert(asl::same_as<decltype(b2), asl::option<float>>);
|
||||
ASL_TEST_ASSERT(!b2.has_value());
|
||||
}
|
||||
|
||||
@ -250,12 +250,12 @@ ASL_TEST(transform)
|
||||
auto fn = [](int x) -> float { return static_cast<float>(x) + 0.5F; };
|
||||
|
||||
auto a2 = a.transform(fn);
|
||||
static_assert(asl::is_same<decltype(a2), asl::option<float>>);
|
||||
static_assert(asl::same_as<decltype(a2), asl::option<float>>);
|
||||
ASL_TEST_ASSERT(a2.has_value());
|
||||
ASL_TEST_EXPECT(a2.value() == 5.5F);
|
||||
|
||||
auto b2 = b.transform(fn);
|
||||
static_assert(asl::is_same<decltype(b2), asl::option<float>>);
|
||||
static_assert(asl::same_as<decltype(b2), asl::option<float>>);
|
||||
ASL_TEST_ASSERT(!b2.has_value());
|
||||
}
|
||||
|
||||
@ -267,12 +267,12 @@ ASL_TEST(or_else)
|
||||
auto fn = []() -> asl::option<int> { return 12; };
|
||||
|
||||
auto a2 = a.or_else(fn);
|
||||
static_assert(asl::is_same<decltype(a2), asl::option<int>>);
|
||||
static_assert(asl::same_as<decltype(a2), asl::option<int>>);
|
||||
ASL_TEST_ASSERT(a2.has_value());
|
||||
ASL_TEST_EXPECT(a2.value() == 5);
|
||||
|
||||
auto b2 = b.or_else(fn);
|
||||
static_assert(asl::is_same<decltype(b2), asl::option<int>>);
|
||||
static_assert(asl::same_as<decltype(b2), asl::option<int>>);
|
||||
ASL_TEST_ASSERT(b2.has_value());
|
||||
ASL_TEST_EXPECT(b2.value() == 12);
|
||||
}
|
||||
|
Reference in New Issue
Block a user