diff --git a/include/boost/parser/detail/detection.hpp b/include/boost/parser/detail/detection.hpp index 1b0efacb..4e9a1765 100644 --- a/include/boost/parser/detail/detection.hpp +++ b/include/boost/parser/detail/detection.hpp @@ -1,10 +1,15 @@ +// Copyright (C) 2020 T. Zachary Laine +// +// Distributed under 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) #ifndef BOOST_PARSER_DETAIL_DETECTION_HPP #define BOOST_PARSER_DETAIL_DETECTION_HPP #include -namespace boost { namespace parser { namespace detail { +namespace boost::parser::detail { template struct void_ @@ -16,6 +21,24 @@ namespace boost { namespace parser { namespace detail { template using void_t = typename void_::type; + template + struct fixup_ptr + { + using type = T; + }; + + template + using remove_v_t = typename std::remove_volatile::type; + + template + struct fixup_ptr + { + using type = remove_v_t const *; + }; + + template + using fixup_ptr_t = typename fixup_ptr::type; + template using remove_cv_ref_t = typename std::remove_cv::type>::type; @@ -26,8 +49,7 @@ namespace boost { namespace parser { namespace detail { template< typename Default, typename AlwaysVoid, - template - class Template, + template class Template, typename... Args> struct detector { @@ -37,8 +59,7 @@ namespace boost { namespace parser { namespace detail { template< typename Default, - template - class Template, + template class Template, typename... Args> struct detector>, Template, Args...> { @@ -50,18 +71,20 @@ namespace boost { namespace parser { namespace detail { using is_detected = typename detector::value_t; + template class Template, typename... Args> + constexpr bool is_detected_v = is_detected::value; + template class Template, typename... Args> using detected_t = typename detector::type; template< typename Default, - template - class Template, + template class Template, typename... Args> - using detected_or = + using detected_or_t = typename detector::type; -}}} +} #endif diff --git a/include/boost/parser/detail/hl.hpp b/include/boost/parser/detail/hl.hpp index 413fea45..b44e326a 100644 --- a/include/boost/parser/detail/hl.hpp +++ b/include/boost/parser/detail/hl.hpp @@ -196,7 +196,7 @@ namespace boost { namespace parser { namespace detail::hl { template constexpr bool operator()(T const & t, U const & u) { - if constexpr (detail::is_detected::value) { + if constexpr (detail::is_detected_v) { return t == u; } else { return false; diff --git a/include/boost/parser/detail/printing.hpp b/include/boost/parser/detail/printing.hpp index 5bf56489..39225e5f 100644 --- a/include/boost/parser/detail/printing.hpp +++ b/include/boost/parser/detail/printing.hpp @@ -407,7 +407,7 @@ namespace boost { namespace parser { namespace detail { using streamable = decltype(std::declval() << std::declval()); - template{}> + template> struct printer { std::ostream & operator()(std::ostream & os, T const &) diff --git a/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp b/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp index cc61a86e..03ca52f2 100644 --- a/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp +++ b/include/boost/parser/detail/stl_interfaces/view_adaptor.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -50,10 +50,6 @@ namespace boost::parser::detail { namespace stl_interfaces { namespace detail { - template class Template, typename... Args> - constexpr bool is_detected_v = - text::detail::is_detected::value; - template using invocable_expr = decltype(std::declval()(std::declval()...)); diff --git a/include/boost/parser/detail/text/detail/algorithm.hpp b/include/boost/parser/detail/text/detail/algorithm.hpp index 07e1c4c4..77f86571 100644 --- a/include/boost/parser/detail/text/detail/algorithm.hpp +++ b/include/boost/parser/detail/text/detail/algorithm.hpp @@ -7,7 +7,7 @@ #define BOOST_PARSER_DETAIL_TEXT_DETAIL_ALGORITHM_HPP #include -#include +#include #include #include diff --git a/include/boost/parser/detail/text/detail/begin_end.hpp b/include/boost/parser/detail/text/detail/begin_end.hpp index ec469d4c..773dfda6 100644 --- a/include/boost/parser/detail/text/detail/begin_end.hpp +++ b/include/boost/parser/detail/text/detail/begin_end.hpp @@ -6,7 +6,7 @@ #ifndef BOOST_PARSER_DETAIL_TEXT_BEGIN_END_HPP #define BOOST_PARSER_DETAIL_TEXT_BEGIN_END_HPP -#include +#include #include @@ -35,10 +35,9 @@ namespace boost::parser::detail { namespace text { namespace detail { template using adl_begin_expr = decltype(begin(std::declval())); template - constexpr bool has_member_begin_v = - is_detected::value; + constexpr bool has_member_begin_v = is_detected_v; template - constexpr bool has_adl_begin_v = is_detected::value; + constexpr bool has_adl_begin_v = is_detected_v; template using member_return_t = @@ -99,10 +98,9 @@ namespace boost::parser::detail { namespace text { namespace detail { template using adl_end_expr = decltype(end(std::declval())); template - constexpr bool has_member_end_v = - is_detected::value; + constexpr bool has_member_end_v = is_detected_v; template - constexpr bool has_adl_end_v = is_detected::value; + constexpr bool has_adl_end_v = is_detected_v; template using member_return_t = diff --git a/include/boost/parser/detail/text/detail/detection.hpp b/include/boost/parser/detail/text/detail/detection.hpp deleted file mode 100644 index 210adc81..00000000 --- a/include/boost/parser/detail/text/detail/detection.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2020 T. Zachary Laine -// -// Distributed under 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) -#ifndef BOOST_PARSER_DETAIL_TEXT_DETAIL_DETECTION_HPP -#define BOOST_PARSER_DETAIL_TEXT_DETAIL_DETECTION_HPP - -#include - - -namespace boost::parser::detail { namespace text { namespace detail { - - template - struct void_ - { - using type = void; - static constexpr bool value = true; - }; - - template - using void_t = typename void_::type; - - template - struct fixup_ptr - { - using type = T; - }; - - template - using remove_v_t = typename std::remove_volatile::type; - - template - struct fixup_ptr - { - using type = remove_v_t const *; - }; - - template - using fixup_ptr_t = typename fixup_ptr::type; - - template - using remove_cv_ref_t = - typename std::remove_cv::type>::type; - - struct nonesuch - {}; - - template< - typename Default, - typename AlwaysVoid, - template class Template, - typename... Args> - struct detector - { - using value_t = std::false_type; - using type = Default; - }; - - template< - typename Default, - template class Template, - typename... Args> - struct detector>, Template, Args...> - { - using value_t = std::true_type; - using type = Template; - }; - - template class Template, typename... Args> - using is_detected = - typename detector::value_t; - - template class Template, typename... Args> - constexpr bool is_detected_v = is_detected::value; - - template class Template, typename... Args> - using detected_t = - typename detector::type; - - template< - typename Default, - template class Template, - typename... Args> - using detected_or_t = - typename detector::type; - -}}} - -#endif diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index 9d1f841d..a64d44ae 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -748,7 +748,7 @@ namespace boost { namespace parser { template< typename Context, typename T, - bool Callable = is_detected{}> + bool Callable = is_detected_v> struct resolve_impl { static auto call(Context const &, T const & x) { return x; } @@ -857,7 +857,7 @@ namespace boost { namespace parser { template constexpr bool is_equality_comparable_with_v = - is_detected::value; + is_detected_v; template struct is_nope : std::false_type @@ -936,7 +936,7 @@ namespace boost { namespace parser { {}; template - constexpr bool is_invocable_v = is_detected::value; + constexpr bool is_invocable_v = is_detected_v; #if BOOST_PARSER_USE_CONCEPTS @@ -982,8 +982,8 @@ namespace boost { namespace parser { std::declval().end())); template - constexpr bool is_container_v = is_detected::value && - is_detected::value; + constexpr bool is_container_v = + is_detected_v && is_detected_v; template constexpr bool container_and_value_type = is_container_v && @@ -1008,7 +1008,7 @@ namespace boost { namespace parser { template constexpr bool is_parsable_range_v = is_parsable_code_unit_v< remove_cv_ref_t>> && - is_detected::value; + is_detected_v; template constexpr bool is_parsable_pointer_v =