mirror of
https://github.com/boostorg/spirit.git
synced 2026-01-19 04:42:11 +00:00
tested compliance by all (most?) iterators provided
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
# Copyright (c) 2001-2011 Joel de Guzman
|
||||
# Copyright (c) 2001-2012 Hartmut Kaiser
|
||||
# Copyright (c) 2011 Bryce Lelbach
|
||||
# Copyright (c) 2025 Joaquin M Lopez Munoz
|
||||
#
|
||||
# Use, modification and distribution is subject to the Boost Software
|
||||
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -67,4 +68,5 @@ run unused_type.cpp ;
|
||||
run utree.cpp ;
|
||||
run utree_debug.cpp ;
|
||||
|
||||
compile iterator_concepts.cpp ;
|
||||
compile multi_pass_functor.cpp ;
|
||||
|
||||
83
test/support/iterator_concepts.cpp
Normal file
83
test/support/iterator_concepts.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
// Copyright (c) 2025 Joaquin M Lopez Munoz
|
||||
//
|
||||
// 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)
|
||||
|
||||
// Compliance with Boost.ConceptCheck/C++20 iterator concepts
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/spirit/home/classic/iterator/file_iterator.hpp>
|
||||
#include <boost/spirit/home/classic/iterator/fixed_size_queue.hpp>
|
||||
#include <boost/spirit/home/classic/iterator/multi_pass.hpp>
|
||||
#include <boost/spirit/home/classic/iterator/position_iterator.hpp>
|
||||
#include <boost/spirit/home/karma/stream/ostream_iterator.hpp>
|
||||
#include <boost/spirit/home/lex/lexer/lexertl/iterator.hpp>
|
||||
#include <boost/spirit/home/support/iterators/istream_iterator.hpp>
|
||||
#include <boost/spirit/home/support/iterators/line_pos_iterator.hpp>
|
||||
#include <boost/spirit/home/support/iterators/look_ahead.hpp>
|
||||
#include <boost/spirit/home/support/iterators/multi_pass.hpp>
|
||||
#include <boost/spirit/home/support/iterators/ostream_iterator.hpp>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
template<typename F> struct unparens;
|
||||
template<typename T> struct unparens<void(T)> { typedef T type; };
|
||||
#define UNPARENS(ParensedArg) typename unparens<void ParensedArg>::type
|
||||
|
||||
#if !defined(BOOST_NO_CXX20_HDR_CONCEPTS)
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#define STATIC_ASSERT_OUTPUT_ITERATOR(ParensedIt, T) \
|
||||
static_assert(std::output_iterator<UNPARENS(ParensedIt), T>);
|
||||
#define STATIC_ASSERT_FORWARD_ITERATOR(ParensedIt) \
|
||||
static_assert(std::forward_iterator<UNPARENS(ParensedIt)>);
|
||||
#define STATIC_ASSERT_RANDOM_ACCESS_ITERATOR(ParensedIt) \
|
||||
static_assert(std::random_access_iterator<UNPARENS(ParensedIt)>);
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/concept/assert.hpp>
|
||||
|
||||
#define STATIC_ASSERT_OUTPUT_ITERATOR(ParensedIt, T) \
|
||||
BOOST_CONCEPT_ASSERT((boost::OutputIterator<UNPARENS(ParensedIt), T>));
|
||||
#define STATIC_ASSERT_FORWARD_ITERATOR(ParensedIt) \
|
||||
BOOST_CONCEPT_ASSERT((boost::ForwardIterator<UNPARENS(ParensedIt)>));
|
||||
#define STATIC_ASSERT_RANDOM_ACCESS_ITERATOR(ParensedIt) \
|
||||
BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<UNPARENS(ParensedIt)>));
|
||||
|
||||
#endif
|
||||
|
||||
STATIC_ASSERT_RANDOM_ACCESS_ITERATOR((
|
||||
BOOST_SPIRIT_CLASSIC_NS::file_iterator<>));
|
||||
STATIC_ASSERT_RANDOM_ACCESS_ITERATOR((
|
||||
BOOST_SPIRIT_CLASSIC_NS::fixed_size_queue<char, 10>::iterator));
|
||||
STATIC_ASSERT_RANDOM_ACCESS_ITERATOR((
|
||||
BOOST_SPIRIT_CLASSIC_NS::fixed_size_queue<char, 10>::const_iterator));
|
||||
STATIC_ASSERT_FORWARD_ITERATOR((
|
||||
BOOST_SPIRIT_CLASSIC_NS::multi_pass<std::istream_iterator<char>>));
|
||||
STATIC_ASSERT_FORWARD_ITERATOR((
|
||||
BOOST_SPIRIT_CLASSIC_NS::position_iterator<char*>));
|
||||
STATIC_ASSERT_FORWARD_ITERATOR((
|
||||
BOOST_SPIRIT_CLASSIC_NS::position_iterator2<char*>));
|
||||
STATIC_ASSERT_OUTPUT_ITERATOR(
|
||||
(boost::spirit::karma::ostream_iterator<char, char>),
|
||||
char);
|
||||
STATIC_ASSERT_FORWARD_ITERATOR((
|
||||
boost::spirit::istream_iterator));
|
||||
STATIC_ASSERT_FORWARD_ITERATOR((
|
||||
boost::spirit::line_pos_iterator<std::istream_iterator<char>>));
|
||||
STATIC_ASSERT_FORWARD_ITERATOR((
|
||||
boost::spirit::look_ahead<std::istream_iterator<char>, 10>));
|
||||
STATIC_ASSERT_FORWARD_ITERATOR((
|
||||
boost::spirit::multi_pass<
|
||||
std::istream_iterator<char>,
|
||||
boost::spirit::iterator_policies::default_policy<
|
||||
boost::spirit::iterator_policies::ref_counted,
|
||||
boost::spirit::iterator_policies::no_check,
|
||||
boost::spirit::iterator_policies::input_iterator,
|
||||
boost::spirit::iterator_policies::fixed_size_queue<10>>>));
|
||||
STATIC_ASSERT_OUTPUT_ITERATOR(
|
||||
(boost::spirit::ostream_iterator),
|
||||
char);
|
||||
Reference in New Issue
Block a user