// Range v3 library // // Copyright Eric Niebler 2014-present // Copyright Google LLC 2020-present // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/range-v3 //#define RANGES_USE_LEGACY_CONCEPTS 1 #include #include #include #include #include #include #include #include #include #include "../simple_test.hpp" struct moveonly { moveonly(moveonly&&) = default; moveonly& operator=(moveonly&&) = default; }; struct nonmovable { nonmovable(nonmovable const &) = delete; nonmovable& operator=(nonmovable const &) = delete; }; struct nondefaultconstructible { nondefaultconstructible(int) {} }; struct NotDestructible { ~NotDestructible() = delete; }; struct IntComparable { operator int() const; friend bool operator==(IntComparable, IntComparable); friend bool operator!=(IntComparable, IntComparable); friend bool operator<(IntComparable, IntComparable); friend bool operator>(IntComparable, IntComparable); friend bool operator<=(IntComparable, IntComparable); friend bool operator>=(IntComparable, IntComparable); friend bool operator==(int, IntComparable); friend bool operator!=(int, IntComparable); friend bool operator==(IntComparable, int); friend bool operator!=(IntComparable, int); friend bool operator<(int, IntComparable); friend bool operator<(IntComparable, int); friend bool operator>(int, IntComparable); friend bool operator>(IntComparable, int); friend bool operator<=(int, IntComparable); friend bool operator<=(IntComparable, int); friend bool operator>=(int, IntComparable); friend bool operator>=(IntComparable, int); }; struct IntSwappable { operator int() const; friend void swap(int &, IntSwappable); friend void swap(IntSwappable, int &); friend void swap(IntSwappable, IntSwappable); }; static_assert(ranges::same_as, ""); static_assert(ranges::same_as, ""); static_assert(ranges::same_as, ""); static_assert(!ranges::same_as, ""); static_assert(!ranges::same_as, ""); static_assert(!ranges::same_as, ""); static_assert(ranges::convertible_to, ""); static_assert(ranges::convertible_to, ""); static_assert(ranges::convertible_to, ""); static_assert(!ranges::convertible_to, ""); static_assert(!ranges::convertible_to, ""); static_assert(!ranges::convertible_to, ""); static_assert(ranges::unsigned_integral, ""); static_assert(!ranges::unsigned_integral, ""); static_assert(ranges::assignable_from, ""); static_assert(!ranges::assignable_from, ""); static_assert(!ranges::assignable_from, ""); static_assert(ranges::destructible, ""); static_assert(ranges::destructible, ""); static_assert(!ranges::destructible, ""); static_assert(ranges::destructible, ""); static_assert(!ranges::destructible, ""); static_assert(ranges::destructible, ""); static_assert(ranges::destructible, ""); static_assert(!ranges::destructible, ""); static_assert(ranges::destructible, ""); static_assert(ranges::destructible, ""); static_assert(ranges::destructible, ""); static_assert(ranges::destructible, ""); static_assert(ranges::destructible, ""); static_assert(!ranges::destructible, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); static_assert(!ranges::constructible_from, ""); static_assert(ranges::constructible_from, ""); struct XXX { XXX() = default; XXX(XXX&&) = delete; explicit XXX(int) {} }; static_assert(ranges::constructible_from, ""); static_assert(!ranges::move_constructible, ""); static_assert(!ranges::movable, ""); static_assert(!ranges::semiregular, ""); static_assert(!ranges::regular, ""); static_assert(ranges::default_constructible, ""); static_assert(ranges::default_constructible, ""); static_assert(!ranges::default_constructible, ""); static_assert(!ranges::default_constructible, ""); static_assert(!ranges::default_constructible, ""); static_assert(!ranges::default_constructible, ""); static_assert(ranges::default_constructible, ""); static_assert(!ranges::default_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::destructible, ""); static_assert(ranges::constructible_from, ""); static_assert(ranges::move_constructible, ""); static_assert(!ranges::move_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::move_constructible, ""); static_assert(ranges::copy_constructible, ""); static_assert(ranges::copy_constructible, ""); static_assert(ranges::copy_constructible, ""); static_assert(!ranges::copy_constructible, ""); static_assert(ranges::copy_constructible, ""); static_assert(!ranges::copy_constructible, ""); static_assert(!ranges::copy_constructible, ""); static_assert(!ranges::copy_constructible, ""); static_assert(ranges::copy_constructible, ""); static_assert(!ranges::copy_constructible, ""); static_assert(ranges::copy_constructible, ""); static_assert(!ranges::copy_constructible, ""); static_assert(ranges::movable, ""); static_assert(!ranges::movable, ""); static_assert(ranges::movable, ""); static_assert(!ranges::movable, ""); static_assert(ranges::copyable, ""); static_assert(!ranges::copyable, ""); static_assert(!ranges::copyable, ""); static_assert(!ranges::copyable, ""); // static_assert(ranges::predicate, int, int>, ""); // static_assert(!ranges::predicate, char*, int>, ""); static_assert(ranges::input_iterator, ""); static_assert(!ranges::input_iterator, ""); static_assert(ranges::forward_iterator, ""); static_assert(!ranges::forward_iterator, ""); static_assert(ranges::bidirectional_iterator, ""); static_assert(!ranges::bidirectional_iterator, ""); static_assert(ranges::random_access_iterator, ""); static_assert(!ranges::random_access_iterator, ""); static_assert(ranges::contiguous_iterator, ""); static_assert(!ranges::contiguous_iterator, ""); static_assert(ranges::view_>, ""); static_assert(ranges::input_iterator>>, ""); static_assert(!ranges::view_, ""); static_assert(ranges::common_range >, ""); static_assert(ranges::common_range &>, ""); static_assert(!ranges::view_>, ""); static_assert(!ranges::view_ &>, ""); static_assert(ranges::random_access_iterator const &>>, ""); static_assert(!ranges::common_range>, ""); static_assert(ranges::predicate, int, int>, ""); static_assert(!ranges::predicate, char*, int>, ""); static_assert(ranges::output_iterator, ""); static_assert(!ranges::output_iterator, ""); static_assert(ranges::swappable, ""); static_assert(ranges::swappable, ""); static_assert(!ranges::swappable, ""); static_assert(ranges::swappable, ""); static_assert(ranges::swappable_with, ""); static_assert(!ranges::swappable_with, ""); static_assert(ranges::totally_ordered, ""); static_assert(ranges::common_with, ""); static_assert(ranges::common_reference_with, ""); static_assert(ranges::totally_ordered_with, ""); static_assert(ranges::totally_ordered_with, ""); static_assert(ranges::detail::weakly_equality_comparable_with_, ""); static_assert(ranges::equality_comparable, ""); static_assert(ranges::equality_comparable_with, ""); static_assert(ranges::equality_comparable_with, ""); static_assert(ranges::equality_comparable_with, ""); #if __cplusplus > 201703L && __has_include() && \ defined(__cpp_concepts) && defined(__cpp_impl_three_way_comparison) #include static_assert(ranges::three_way_comparable); static_assert(ranges::three_way_comparable); static_assert(ranges::three_way_comparable); static_assert(ranges::three_way_comparable); static_assert(ranges::three_way_comparable_with); static_assert(ranges::three_way_comparable_with); static_assert(ranges::three_way_comparable_with); static_assert(ranges::three_way_comparable_with); static_assert(ranges::three_way_comparable_with); static_assert(ranges::three_way_comparable_with); static_assert(ranges::three_way_comparable_with); static_assert(ranges::three_way_comparable_with); #endif // supports spaceship static_assert( std::is_same< ranges::common_range_tag_of>, ranges::common_range_tag >::value, ""); static_assert( std::is_same< ranges::sized_range_tag_of>, ranges::sized_range_tag >::value, ""); static_assert(ranges::view_>, ""); static_assert(!ranges::common_range>, ""); static_assert(!ranges::sized_range>, ""); struct myview : ranges::view_base { const char *begin(); const char *end(); }; CPP_assert(ranges::view_); CPP_template(class T) (requires ranges::regular) constexpr bool is_regular(T&&) { return true; } CPP_template(class T) (requires (!ranges::regular)) constexpr bool is_regular(T&&) { return false; } static_assert(is_regular(42), ""); static_assert(!is_regular(XXX{}), ""); int main() { return test_result(); }