/* * Copyright (c) Facebook, Inc. and its affiliates. * * Licensed under the Apache License Version 2.0 with LLVM Exceptions * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * https://llvm.org/LICENSE.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include #include namespace unifex { template UNIFEX_CONCEPT same_as = UNIFEX_IS_SAME(A, B) && UNIFEX_IS_SAME(B, A); template UNIFEX_CONCEPT_FRAGMENT( _explicitly_convertible_to, requires(From(*from)()) // ( static_cast(from()) )); template UNIFEX_CONCEPT convertible_to = std::is_convertible_v, To> && UNIFEX_FRAGMENT(unifex::_explicitly_convertible_to, From, To); /// \cond namespace detail { template using _cref_t = std::remove_reference_t const &; template UNIFEX_CONCEPT_FRAGMENT( _boolean_testable_impl, requires(T && t) ( requires(convertible_to) )); template UNIFEX_CONCEPT _boolean_testable = UNIFEX_FRAGMENT(_boolean_testable_impl, T) && convertible_to; UNIFEX_DIAGNOSTIC_PUSH UNIFEX_DIAGNOSTIC_IGNORE_FLOAT_EQUAL template UNIFEX_CONCEPT_FRAGMENT( _weakly_equality_comparable_with, requires(_cref_t t, _cref_t u) // ( requires(_boolean_testable), requires(_boolean_testable), requires(_boolean_testable), requires(_boolean_testable) )); template UNIFEX_CONCEPT weakly_equality_comparable_with_ = UNIFEX_FRAGMENT(detail::_weakly_equality_comparable_with, T, U); UNIFEX_DIAGNOSTIC_POP } // namespace detail /// \endcond template UNIFEX_CONCEPT_FRAGMENT( _derived_from, requires()(0) && convertible_to); template UNIFEX_CONCEPT derived_from = UNIFEX_IS_BASE_OF(U, T) && UNIFEX_FRAGMENT(unifex::_derived_from, T, U); template UNIFEX_CONCEPT_FRAGMENT( _assignable_from, requires(T t, U && u) // ( t = (U &&) u, requires(same_as) )); template UNIFEX_CONCEPT assignable_from = std::is_lvalue_reference_v && UNIFEX_FRAGMENT(unifex::_assignable_from, T, U); template UNIFEX_CONCEPT_FRAGMENT( _swappable, requires(T & t, T & u) // ( unifex::swap(t, u) )); template UNIFEX_CONCEPT swappable = UNIFEX_FRAGMENT(unifex::_swappable, T); template UNIFEX_CONCEPT_FRAGMENT( _swappable_with, requires(T && t, U && u) // ( unifex::swap((T &&) t, (T &&) t), unifex::swap((U &&) u, (U &&) u), unifex::swap((U &&) u, (T &&) t), unifex::swap((T &&) t, (U &&) u) )); template UNIFEX_CONCEPT swappable_with = //common_reference_with, detail::_cref_t> && UNIFEX_FRAGMENT(unifex::_swappable_with, T, U); //////////////////////////////////////////////////////////////////////////////////////////// // Comparison concepts //////////////////////////////////////////////////////////////////////////////////////////// template UNIFEX_CONCEPT equality_comparable = detail::weakly_equality_comparable_with_; // template // UNIFEX_CONCEPT_FRAGMENT( // _equality_comparable_with, // requires()(0) && // equality_comparable< // common_reference_t, detail::_cref_t>>); template UNIFEX_CONCEPT equality_comparable_with = equality_comparable && equality_comparable && detail::weakly_equality_comparable_with_;// && //common_reference_with, detail::_cref_t> && //UNIFEX_FRAGMENT(unifex::_equality_comparable_with, T, U); template UNIFEX_CONCEPT_FRAGMENT( _totally_ordered, requires(detail::_cref_t t, detail::_cref_t u) // ( requires(detail::_boolean_testable), requires(detail::_boolean_testable u)>), requires(detail::_boolean_testable), requires(detail::_boolean_testable= t)>) )); template UNIFEX_CONCEPT totally_ordered = equality_comparable && UNIFEX_FRAGMENT(unifex::_totally_ordered, T); template UNIFEX_CONCEPT_FRAGMENT( _totally_ordered_with, requires(detail::_cref_t t, detail::_cref_t u) // ( requires(detail::_boolean_testable), requires(detail::_boolean_testable u)>), requires(detail::_boolean_testable), requires(detail::_boolean_testable= u)>), requires(detail::_boolean_testable), requires(detail::_boolean_testable t)>), requires(detail::_boolean_testable), requires(detail::_boolean_testable= t)>) )); //&& totally_ordered< // common_reference_t, detail::_cref_t>> template UNIFEX_CONCEPT totally_ordered_with = totally_ordered && totally_ordered && equality_comparable_with && //common_reference_with, detail::_cref_t> && UNIFEX_FRAGMENT(unifex::_totally_ordered_with, T, U); //////////////////////////////////////////////////////////////////////////////////////////// // Object concepts //////////////////////////////////////////////////////////////////////////////////////////// template UNIFEX_CONCEPT destructible = std::is_nothrow_destructible_v; template UNIFEX_CONCEPT constructible_from = destructible && UNIFEX_IS_CONSTRUCTIBLE(T, Args...); template UNIFEX_CONCEPT default_constructible = constructible_from; template UNIFEX_CONCEPT move_constructible = constructible_from && convertible_to; template UNIFEX_CONCEPT_FRAGMENT( _copy_constructible, requires()(0) && constructible_from && constructible_from && constructible_from && convertible_to && convertible_to && convertible_to); template UNIFEX_CONCEPT copy_constructible = move_constructible && UNIFEX_FRAGMENT(unifex::_copy_constructible, T); template UNIFEX_CONCEPT_FRAGMENT( _move_assignable, requires()(0) && assignable_from); template UNIFEX_CONCEPT movable = std::is_object_v && move_constructible && UNIFEX_FRAGMENT(unifex::_move_assignable, T) && swappable; template UNIFEX_CONCEPT_FRAGMENT( _copy_assignable, requires()(0) && assignable_from); template UNIFEX_CONCEPT copyable = copy_constructible && movable && UNIFEX_FRAGMENT(unifex::_copy_assignable, T); template UNIFEX_CONCEPT semiregular = copyable && default_constructible; // Axiom: copies are independent. See Fundamentals of Generic Programming // http://www.stepanovpapers.com/DeSt98.pdf template UNIFEX_CONCEPT regular = semiregular && equality_comparable; template UNIFEX_CONCEPT // invocable = // std::is_invocable_v; } // namespace unifex #include