Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65788 - in trunk: boost/xpressive libs/xpressive/test
From: eric_at_[hidden]
Date: 2010-10-06 15:02:13


Author: eric_niebler
Date: 2010-10-06 15:02:04 EDT (Wed, 06 Oct 2010)
New Revision: 65788
URL: http://svn.boost.org/trac/boost/changeset/65788

Log:
as() handles wide sub_match objects correctly, fixes #4496
Text files modified:
   trunk/boost/xpressive/regex_actions.hpp | 15 +++++++++++++++
   trunk/libs/xpressive/test/test_actions.cpp | 23 +++++++++++++++++++++++
   2 files changed, 38 insertions(+), 0 deletions(-)

Modified: trunk/boost/xpressive/regex_actions.hpp
==============================================================================
--- trunk/boost/xpressive/regex_actions.hpp (original)
+++ trunk/boost/xpressive/regex_actions.hpp 2010-10-06 15:02:04 EDT (Wed, 06 Oct 2010)
@@ -62,6 +62,21 @@
 #pragma warning(disable : 4610) // can never be instantiated - user defined constructor required
 #endif
 
+namespace boost
+{
+ namespace detail
+ {
+ // Bit of a hack to make lexical_cast work with wide sub_match
+ template<typename T>
+ struct stream_char;
+
+ template<typename BidiIter>
+ struct stream_char<xpressive::sub_match<BidiIter> >
+ : boost::iterator_value<BidiIter>
+ {};
+ }
+}
+
 namespace boost { namespace xpressive
 {
 

Modified: trunk/libs/xpressive/test/test_actions.cpp
==============================================================================
--- trunk/libs/xpressive/test/test_actions.cpp (original)
+++ trunk/libs/xpressive/test/test_actions.cpp 2010-10-06 15:02:04 EDT (Wed, 06 Oct 2010)
@@ -224,6 +224,28 @@
     }
 }
 
+///////////////////////////////////////////////////////////////////////////////
+// test6
+// Test as<>() with wide strings. Bug #4496.
+void test6()
+{
+ using namespace boost::xpressive;
+
+ std::wstring version(L"0.9.500");
+
+ local<int> maj1(0), min1(0), build1(0);
+
+ wsregex re1 = (+_d)[maj1 = as<int>(_)] >> L"." >>
+ (+_d)[min1 = as<int>(_)] >> L"." >>
+ (+_d)[build1 = as<int>(_)];
+
+ BOOST_REQUIRE(regex_match(version, re1));
+
+ BOOST_CHECK_EQUAL(maj1.get(), 0);
+ BOOST_CHECK_EQUAL(min1.get(), 9);
+ BOOST_CHECK_EQUAL(build1.get(), 500);
+}
+
 using namespace boost::unit_test;
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -238,6 +260,7 @@
     test->add(BOOST_TEST_CASE(&test4));
     test->add(BOOST_TEST_CASE(&test4_aux));
     test->add(BOOST_TEST_CASE(&test5));
+ test->add(BOOST_TEST_CASE(&test6));
     return test;
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk