|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74905 - in trunk/boost/spirit/home: karma/string qi/string
From: joel_at_[hidden]
Date: 2011-10-10 20:23:34
Author: djowel
Date: 2011-10-10 20:23:34 EDT (Mon, 10 Oct 2011)
New Revision: 74905
URL: http://svn.boost.org/trac/boost/changeset/74905
Log:
Added rvalue support for symbols %=
Text files modified:
trunk/boost/spirit/home/karma/string/symbols.hpp | 47 +++++++++++++++++++++++++++------------
trunk/boost/spirit/home/qi/string/symbols.hpp | 19 +++++++++++++++
2 files changed, 50 insertions(+), 16 deletions(-)
Modified: trunk/boost/spirit/home/karma/string/symbols.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/string/symbols.hpp (original)
+++ trunk/boost/spirit/home/karma/string/symbols.hpp 2011-10-10 20:23:34 EDT (Mon, 10 Oct 2011)
@@ -1,6 +1,6 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
+//
+// 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)
#if !defined(BOOST_SPIRIT_KARMA_SYMBOLS_NOV_23_2009_1251PM)
@@ -37,11 +37,11 @@
template <typename T, typename Attribute, typename Enable>
struct symbols_lookup
{
- typedef
+ typedef
mpl::eval_if<fusion::traits::is_sequence<T>
, traits::detail::value_at_c<T, 0>
, detail::add_const_ref<T> > sequence_type;
- typedef typename
+ typedef typename
mpl::eval_if<traits::is_container<T>
, traits::container_value<T>
, sequence_type>::type type;
@@ -90,11 +90,11 @@
template <typename Attribute, typename T, typename Enable>
struct symbols_value
{
- typedef
+ typedef
mpl::eval_if<fusion::traits::is_sequence<T>
, traits::detail::value_at_c<T, 1>
, mpl::identity<unused_type> > sequence_type;
- typedef typename
+ typedef typename
mpl::eval_if<traits::is_container<T>
, traits::container_value<T>
, sequence_type>::type type;
@@ -150,7 +150,7 @@
: mpl::if_<
traits::not_is_unused<T>
, std::map<Attribute, T>
- , std::set<Attribute>
+ , std::set<Attribute>
>
{};
@@ -161,7 +161,7 @@
template <typename CharEncoding, typename Tag>
struct generate_encoded
{
- typedef typename
+ typedef typename
proto::terminal<tag::char_code<Tag, CharEncoding> >::type
encoding_type;
@@ -298,6 +298,7 @@
return sym.remove(attr);
}
+#if defined(BOOST_NO_RVALUE_REFERENCES)
// non-const version needed to suppress proto's += kicking in
template <typename Attr, typename T_>
friend adder const&
@@ -313,7 +314,23 @@
{
return sym.remove(attr);
}
+#else
+ // for rvalue references
+ template <typename Attr, typename T_>
+ friend adder const&
+ operator+= (symbols& sym, std::pair<Attr, T_>&& p)
+ {
+ return sym.add(p.first, p.second);
+ }
+ // for rvalue references
+ template <typename Attr>
+ friend remover const&
+ operator-= (symbols& sym, Attr&& attr)
+ {
+ return sym.remove(attr);
+ }
+#endif
template <typename F>
void for_each(F f) const
{
@@ -346,7 +363,7 @@
return karma::detail::generate_encoded<CharEncoding, Tag>::call(
sink, (*it).second
- , traits::symbols_value<Attribute, Attr>::call(attr)) &&
+ , traits::symbols_value<Attribute, Attr>::call(attr)) &&
karma::delimit_out(sink, d);
}
@@ -586,7 +603,7 @@
value_type at(Attr const& attr)
{
typename Lookup::iterator it = lookup->find(attr);
- if (it == lookup->end())
+ if (it == lookup->end())
add(attr);
return unused;
}
@@ -605,7 +622,7 @@
return karma::detail::generate_encoded<CharEncoding, Tag>::
call(sink
, traits::symbols_lookup<Attr, Attribute>::call(attr)
- , unused) &&
+ , unused) &&
karma::delimit_out(sink, d);
}
@@ -706,13 +723,13 @@
reference<symbols<Attribute, T, Lookup, CharEnconding, Tag> >
, Modifiers>
{
- static bool const lower =
+ static bool const lower =
has_modifier<Modifiers, tag::char_code_base<tag::lower> >::value;
- static bool const upper =
+ static bool const upper =
has_modifier<Modifiers, tag::char_code_base<tag::upper> >::value;
typedef reference<
- symbols<Attribute, T, Lookup, CharEnconding, Tag>
+ symbols<Attribute, T, Lookup, CharEnconding, Tag>
> reference_;
typedef typename mpl::if_c<
@@ -740,7 +757,7 @@
, typename Attr, typename Context, typename Iterator>
struct handles_container<karma::symbols<Attribute, T, Lookup, CharEncoding, Tag>
, Attr, Context, Iterator>
- : traits::is_container<Attr> {};
+ : traits::is_container<Attr> {};
}}}
#if defined(BOOST_MSVC)
Modified: trunk/boost/spirit/home/qi/string/symbols.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/string/symbols.hpp (original)
+++ trunk/boost/spirit/home/qi/string/symbols.hpp 2011-10-10 20:23:34 EDT (Mon, 10 Oct 2011)
@@ -166,6 +166,7 @@
return sym.remove(str);
}
+#if defined(BOOST_NO_RVALUE_REFERENCES)
// non-const version needed to suppress proto's += kicking in
template <typename Str>
friend adder const&
@@ -181,7 +182,23 @@
{
return sym.remove(str);
}
+#else
+ // for rvalue references
+ template <typename Str>
+ friend adder const&
+ operator+=(symbols& sym, Str&& str)
+ {
+ return sym.add(str);
+ }
+ // for rvalue references
+ template <typename Str>
+ friend remover const&
+ operator-=(symbols& sym, Str&& str)
+ {
+ return sym.remove(str);
+ }
+#endif
template <typename F>
void for_each(F f) const
{
@@ -404,7 +421,7 @@
template <typename Char, typename T, typename Lookup, typename Filter
, typename Attr, typename Context, typename Iterator>
struct handles_container<qi::symbols<Char, T, Lookup, Filter>, Attr, Context, Iterator>
- : traits::is_container<Attr> {};
+ : traits::is_container<Attr> {};
}}}
#if defined(BOOST_MSVC)
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