///\file /****************************************************************************** The MIT License(MIT) Embedded Template Library. https://github.com/ETLCPP/etl https://www.etlcpp.com Copyright(c) 2021 jwellbelove 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_CLASS_TRAITS_INCLUDED #define ETL_CLASS_TRAITS_INCLUDED #include #include #include #include "platform.h" #if ETL_CPP11_SUPPORTED namespace etl { #if ETL_CPP11_SUPPORTED //*************************************************************************** /// has_member_function_begin //*************************************************************************** template class has_begin { typedef char one; struct two { char x[2]; }; template static constexpr one test(decltype(&C::begin)*); template static constexpr two test(...); public: static constexpr bool value = (sizeof(test(0)) == sizeof(char)); }; #if ETL_CPP17_SUPPORTED template static constexpr bool has_begin_v = has_begin::value; #endif //*************************************************************************** /// has_member_function_end //*************************************************************************** template class has_end { typedef char one; struct two { char x[2]; }; template static constexpr one test(decltype(std::declval().end())); template static constexpr two test(...); public: static constexpr bool value = (sizeof(test(0)) == sizeof(char)); }; #if ETL_CPP17_SUPPORTED template static constexpr bool has_end_v = hasend::value; #endif //*************************************************************************** /// has_member_function_size //*************************************************************************** template class has_size { typedef char one; struct two { char x[2]; }; template static one test(decltype(std::declval().size())); template static two test(...); public: static constexpr bool value = (sizeof(test(0)) == sizeof(char)); }; #if ETL_CPP17_SUPPORTED template static constexpr bool has_size_v = has_size::value; #endif //*************************************************************************** /// has_member_function_max_size //*************************************************************************** template class has_max_size { typedef char one; struct two { char x[2]; }; template static one test(decltype(std::declval().max_size())); template static two test(...); public: static constexpr bool value = (sizeof(test(0)) == sizeof(char)); }; #if ETL_CPP17_SUPPORTED template static constexpr bool has_max_size_v = has_max_size::value; #endif //*************************************************************************** /// has_member_function_empty //*************************************************************************** template class has_empty { typedef char one; struct two { char x[2]; }; template static constexpr one test(decltype(std::declval().empty())); template static constexpr two test(...); public: static constexpr bool value = (sizeof(test(0)) == sizeof(char)); }; #if ETL_CPP17_SUPPORTED template static constexpr bool has_empty_v = has_empty::value; #endif //*************************************************************************** /// has_member_function_data //*************************************************************************** template class has_data { typedef char one; struct two { char x[2]; }; template static constexpr one test(decltype(std::declval().data())); template static constexpr two test(...); public: static constexpr bool value = (sizeof(test(0)) == sizeof(char)); }; #if ETL_CPP17_SUPPORTED template static constexpr bool has_data_v = has_data::value; #endif #endif } #endif #endif // ETL_CLASS_TRAITS_INCLUDED