/** This file is a part of rexy's general purpose library Copyright (C) 2020 rexy712 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef REXY_TRAITS_HPP #define REXY_TRAITS_HPP #include //is_same, decay, integral_constant, declval #include //iterator_traits #include "rexy.hpp" namespace rexy{ template struct is_type{ static std::true_type check(U*); static std::false_type check(...); static constexpr bool value = decltype(check(std::declval*>()))::value; }; template class U> struct is_template_type_helper{ static constexpr bool value = false; }; template class U, class... Args> struct is_template_type_helper,U>{ static constexpr bool value = true; }; template class U> struct is_template_type : public is_template_type_helper,U>{}; template class Tmpl> struct is_template_derived_type{ template static std::true_type test(Tmpl*); static std::false_type test(void*); static constexpr bool value = std::is_same*>(nullptr)))>::value; }; template struct is_dereferencable : public std::false_type{}; template struct is_dereferencable()))>> : public std::true_type{}; template static constexpr bool is_dereferencable_v = is_dereferencable::value; template struct is_pointer_dereferencable : public std::false_type{}; template struct is_pointer_dereferencable().operator->())>> : public std::true_type{}; template struct is_pointer_dereferencable> : public std::true_type{}; template static constexpr bool is_pointer_dereferencable_v = is_pointer_dereferencable::value; template struct is_prefix_incrementable : public std::false_type{}; template struct is_prefix_incrementable>>()))>> : public std::true_type{}; template static constexpr bool is_prefix_incrementable_v = is_prefix_incrementable::value; template struct is_postfix_incrementable : public std::false_type{}; template struct is_postfix_incrementable>>())++)>> : public std::true_type{}; template static constexpr bool is_postfix_incrementable_v = is_postfix_incrementable::value; template struct is_equality_comparable : public std::false_type{}; template struct is_equality_comparable() == std::declval())>> : public std::true_type{}; template static constexpr bool is_equality_comparable_v = is_equality_comparable::value; template struct is_inequality_comparable : public std::false_type{}; template struct is_inequality_comparable() != std::declval())>> : public std::true_type{}; template static constexpr bool is_inequality_comparable_v = is_inequality_comparable::value; template struct is_legacy_iterator{ static constexpr bool value = is_prefix_incrementable_v && is_dereferencable_v; }; template static constexpr bool is_legacy_iterator_v = is_legacy_iterator::value; template && is_inequality_comparable_v && is_pointer_dereferencable_v && is_postfix_incrementable_v> struct is_legacy_input_iterator : public std::false_type{}; template struct is_legacy_input_iterator{ static constexpr bool value = std::is_convertible_v() == std::declval()),bool> && std::is_same_v())),typename std::iterator_traits::reference> && std::is_same_v>>()),std::add_lvalue_reference_t> && std::is_convertible_v>>()++), typename std::iterator_traits::value_type>; }; template static constexpr bool is_legacy_input_iterator_v = is_legacy_input_iterator::value; template && is_postfix_incrementable_v> struct is_legacy_output_iterator : public std::false_type{}; template struct is_legacy_output_iterator{ static constexpr bool value = std::is_same_v>>()),std::add_lvalue_reference_t> && std::is_convertible_v>>()++), std::add_lvalue_reference_t>>; }; template static constexpr bool is_legacy_output_iterator_v = is_legacy_output_iterator::value; } #endif