1 // Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey 2 // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ 3 4 #ifndef TAO_PEGTL_INTERNAL_RULE_CONJUNCTION_HPP 5 #define TAO_PEGTL_INTERNAL_RULE_CONJUNCTION_HPP 6 7 #include "../apply_mode.hpp" 8 #include "../config.hpp" 9 #include "../rewind_mode.hpp" 10 11 namespace tao 12 { 13 namespace TAO_PEGTL_NAMESPACE 14 { 15 namespace internal 16 { 17 template< typename... Rules > 18 struct rule_conjunction; 19 20 template<> 21 struct rule_conjunction<> 22 { 23 template< apply_mode A, 24 rewind_mode M, 25 template< typename... > class Action, 26 template< typename... > class Control, 27 typename Input, 28 typename... States > matchtao::TAO_PEGTL_NAMESPACE::internal::rule_conjunction29 static bool match( Input& /*unused*/, States&&... /*unused*/ ) noexcept 30 { 31 return true; 32 } 33 }; 34 35 template< typename... Rules > 36 struct rule_conjunction 37 { 38 template< apply_mode A, 39 rewind_mode M, 40 template< typename... > class Action, 41 template< typename... > class Control, 42 typename Input, 43 typename... States > matchtao::TAO_PEGTL_NAMESPACE::internal::rule_conjunction44 static bool match( Input& in, States&&... st ) 45 { 46 #ifdef __cpp_fold_expressions 47 return ( Control< Rules >::template match< A, M, Action, Control >( in, st... ) && ... ); 48 #else 49 bool result = true; 50 using swallow = bool[]; 51 (void)swallow{ result = result && Control< Rules >::template match< A, M, Action, Control >( in, st... )... }; 52 return result; 53 #endif 54 } 55 }; 56 57 } // namespace internal 58 59 } // namespace TAO_PEGTL_NAMESPACE 60 61 } // namespace tao 62 63 #endif 64