2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 04:42:11 +00:00

Revert "Merge pull request #824 from saki7/modernize-omit"

This reverts commit a80d412b0e, reversing
changes made to 495f936af2.
This commit is contained in:
Nana Sakisaka
2025-09-13 08:57:01 +09:00
parent 069d2a0162
commit 5d52405c56
2 changed files with 25 additions and 43 deletions

View File

@@ -1,6 +1,5 @@
/*=============================================================================
Copyright (c) 2001-2014 Joel de Guzman
Copyright (c) 2025 Nana Sakisaka
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)
@@ -11,58 +10,42 @@
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/spirit/home/x3/core/parser.hpp>
#include <iterator>
#include <type_traits>
#include <utility>
namespace boost::spirit::x3
namespace boost { namespace spirit { namespace x3
{
// `omit_directive` forces the attribute of subject parser
// to be `unused_type`
///////////////////////////////////////////////////////////////////////////
// omit_directive forces the attribute of subject parser
// to be unused_type
///////////////////////////////////////////////////////////////////////////
template <typename Subject>
struct omit_directive : unary_parser<Subject, omit_directive<Subject>>
{
using base_type = unary_parser<Subject, omit_directive<Subject>>;
using attribute_type = unused_type;
using subject_type = Subject;
static constexpr bool has_attribute = false;
typedef unary_parser<Subject, omit_directive<Subject> > base_type;
typedef unused_type attribute_type;
static bool const has_attribute = false;
template <typename SubjectT>
requires std::is_constructible_v<Subject, SubjectT>
constexpr omit_directive(SubjectT&& subject)
noexcept(std::is_nothrow_constructible_v<Subject, SubjectT>)
: base_type(std::forward<SubjectT>(subject))
{}
typedef Subject subject_type;
constexpr omit_directive(Subject const& subject)
: base_type(subject) {}
template <std::forward_iterator It, std::sentinel_for<It> Se, typename Context, typename RContext>
[[nodiscard]] constexpr bool
parse(
It& first, Se const& last, Context const& context, RContext& rcontext, unused_type
) const noexcept(is_nothrow_parsable_v<Subject, It, Se, Context, RContext, unused_type>)
template <typename Iterator, typename Context, typename RContext>
bool parse(Iterator& first, Iterator const& last
, Context const& context, RContext& rcontext, unused_type) const
{
static_assert(Parsable<Subject, It, Se, Context, RContext, unused_type>);
return this->subject.parse(first, last, context, rcontext, unused);
}
};
namespace detail
struct omit_gen
{
struct omit_gen
template <typename Subject>
constexpr omit_directive<typename extension::as_parser<Subject>::value_type>
operator[](Subject const& subject) const
{
template <X3Subject Subject>
[[nodiscard]] constexpr omit_directive<as_parser_plain_t<Subject>>
operator[](Subject&& subject) const
noexcept(is_parser_nothrow_constructible_v<omit_directive<as_parser_plain_t<Subject>>, as_parser_t<Subject>>)
{
return { as_parser(std::forward<Subject>(subject)) };
}
};
} // detail
return { as_parser(subject) };
}
};
inline namespace cpos
{
inline constexpr detail::omit_gen omit{};
}
} // boost::spirit::x3
constexpr auto omit = omit_gen{};
}}}
#endif

View File

@@ -5,14 +5,13 @@
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)
=============================================================================*/
#include "test.hpp"
#include <boost/spirit/home/x3.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/at.hpp>
#include <string>
#include <iostream>
#include "test.hpp"
using boost::spirit::x3::rule;
@@ -27,7 +26,7 @@ BOOST_SPIRIT_X3_DEFINE(indirect_rule)
int main()
{
using namespace boost::spirit::x3::standard;
using namespace boost::spirit::x3::ascii;
using boost::spirit::x3::omit;
using boost::spirit::x3::unused_type;
using boost::spirit::x3::unused;