/// \file // Range v3 library // // Copyright Eric Niebler 2013-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 // #ifndef RANGES_V3_ACTION_CONCEPTS_HPP #define RANGES_V3_ACTION_CONCEPTS_HPP #include #include #include #include #include namespace ranges { /// \cond namespace detail { template struct movable_input_iterator { using iterator_category = std::input_iterator_tag; using value_type = T; using difference_type = std::ptrdiff_t; using pointer = T *; using reference = T &&; movable_input_iterator() = default; movable_input_iterator & operator++(); movable_input_iterator operator++(int); bool operator==(movable_input_iterator const &) const; bool operator!=(movable_input_iterator const &) const; T && operator*() const; }; } // namespace detail /// \endcond /// \addtogroup group-range /// @{ // std::array is a semi_container, native arrays are not. // clang-format off CPP_def ( template(typename T) concept semi_container, forward_range && default_constructible> && movable> && !view_ ); // std::vector is a container, std::array is not CPP_def ( template(typename T) concept container, semi_container && constructible_from< uncvref_t, detail::movable_input_iterator>, detail::movable_input_iterator>> ); CPP_def ( template(typename C) concept reservable, requires (C &c, C const &cc, range_size_t s) ( c.reserve(s), cc.capacity(), cc.max_size(), concepts::requires_>>, concepts::requires_>> ) && container && sized_range ); CPP_def ( template(typename C, typename I) concept reservable_with_assign, requires (C &c, I i) ( c.assign(i, i) ) && reservable && input_iterator ); CPP_def ( template(typename C) concept random_access_reservable, reservable && random_access_range ); // clang-format on /// \cond namespace detail { template auto is_lvalue_container_like(T &) noexcept -> CPP_ret(std::true_type)( // requires container) { return {}; } template auto is_lvalue_container_like(reference_wrapper) noexcept -> CPP_ret(meta::not_>)( // requires container) { return {}; } template auto is_lvalue_container_like(std::reference_wrapper) noexcept -> CPP_ret(std::true_type)( // requires container) { return {}; } template auto is_lvalue_container_like(ref_view) noexcept -> CPP_ret(std::true_type)( // requires container) { return {}; } template using is_lvalue_container_like_t = decltype(detail::is_lvalue_container_like(std::declval())); } // namespace detail /// \endcond // clang-format off CPP_def ( template(typename T) concept lvalue_container_like, implicitly_convertible_to, std::true_type> && forward_range ); // clang-format on /// @} } // namespace ranges #endif