///\file /****************************************************************************** The MIT License(MIT) Embedded Template Library. https://github.com/ETLCPP/etl https://www.etlcpp.com Copyright(c) 2025 BMW AG Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ #ifndef ETL_CONCEPTS_INCLUDED #define ETL_CONCEPTS_INCLUDED #include "platform.h" #include "type_traits.h" #include "utility.h" #if ETL_NOT_USING_CPP20 && !defined(ETL_IN_UNIT_TEST) #error NOT SUPPORTED FOR BELOW C++20 #endif #if ETL_USING_CPP20 #if ETL_USING_STL #include #endif namespace etl { #if ETL_USING_STL using std::assignable_from; using std::common_reference_with; using std::common_with; using std::convertible_to; using std::derived_from; using std::floating_point; using std::integral; using std::same_as; using std::signed_integral; using std::unsigned_integral; #else // not ETL_USING_STL namespace private_concepts { template concept same_as_helper = etl::is_same_v; } //*************************************************************************** template concept same_as = private_concepts::same_as_helper && private_concepts::same_as_helper; //*************************************************************************** template concept derived_from = etl::is_base_of_v && etl::is_convertible_v; //*************************************************************************** template concept convertible_to = etl::is_convertible_v && requires { static_cast(etl::declval()); }; //*************************************************************************** template < class T, typename U > concept common_reference_with = etl::same_as, etl::common_reference_t > && etl::convertible_to > && etl::convertible_to >; //*************************************************************************** template concept common_with = etl::same_as, etl::common_type_t > && requires { static_cast >(etl::declval()); static_cast >(etl::declval()); } && etl::common_reference_with< etl::add_lvalue_reference_t, etl::add_lvalue_reference_t > && etl::common_reference_with< etl::add_lvalue_reference_t >, etl::common_reference_t< etl::add_lvalue_reference_t, etl::add_lvalue_reference_t > >; //*************************************************************************** template concept integral = etl::is_integral_v; //*************************************************************************** template concept signed_integral = etl::integral && etl::is_signed_v; //*************************************************************************** template concept unsigned_integral = etl::integral && !etl::signed_integral; //*************************************************************************** template concept floating_point = etl::is_floating_point_v; //*************************************************************************** template concept assignable_from = etl::is_lvalue_reference_v && etl::common_reference_with< const etl::remove_reference_t&, const etl::remove_reference_t&> && requires(LHS lhs, RHS&& rhs) { { lhs = etl::forward(rhs) } -> etl::same_as; }; #endif } // namespace etl #endif #endif