From 3fde6e8ddd9bba81d8b3cfec1cd709f4c7c7c3ce Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Thu, 19 Mar 2015 18:14:41 +0000 Subject: [PATCH] Make sub_match a valid range as per https://svn.boost.org/trac/boost/ticket/11036 --- include/boost/regex/v4/sub_match.hpp | 5 ++++ test/Jamfile.v2 | 7 ++--- test/concepts/range_concept_check.cpp | 41 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 test/concepts/range_concept_check.cpp diff --git a/include/boost/regex/v4/sub_match.hpp b/include/boost/regex/v4/sub_match.hpp index 7ce8d539..84c181eb 100644 --- a/include/boost/regex/v4/sub_match.hpp +++ b/include/boost/regex/v4/sub_match.hpp @@ -162,6 +162,11 @@ public: #endif return *this; } + // + // Make this type a range, for both Boost.Range, and C++11: + // + BidiIterator begin()const; + BidiIterator end()const; #ifdef BOOST_OLD_REGEX_H diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 0bf23c83..d6aa8a44 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -149,10 +149,9 @@ test-suite regex : : : always_show_run_output : test_collate_info ] - [ compile concepts/concept_check.cpp ../build//boost_regex - ] - [ compile concepts/icu_concept_check.cpp ../build//boost_regex - ] + [ compile concepts/concept_check.cpp ] + [ compile concepts/icu_concept_check.cpp ] + [ compile concepts/range_concept_check.cpp ] [ run # sources diff --git a/test/concepts/range_concept_check.cpp b/test/concepts/range_concept_check.cpp new file mode 100644 index 00000000..f6afd700 --- /dev/null +++ b/test/concepts/range_concept_check.cpp @@ -0,0 +1,41 @@ +/* +* +* Copyright (c) 2015 +* John Maddock +* +* Use, modification and distribution are subject to 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 +#include + +template +void use_val(const T&){} + +template +void check() +{ + BOOST_CONCEPT_ASSERT((boost::ForwardRangeConcept)); + BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept::type>)); + BOOST_CONCEPT_ASSERT((boost_concepts::RandomAccessTraversalConcept::type>)); + +#ifndef BOOST_NO_CXX11_RANGE_BASED_FOR + const T val; + for(auto item : val) + { + use_val(item); + } +#endif +} + +int main() +{ + check(); + check(); + + check >(); + return 0; +}