Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72871 - in sandbox/coerce/boost/coerce: . detail
From: vexocide_at_[hidden]
Date: 2011-07-03 09:21:35


Author: vexocide
Date: 2011-07-03 09:21:34 EDT (Sun, 03 Jul 2011)
New Revision: 72871
URL: http://svn.boost.org/trac/boost/changeset/72871

Log:
Added a customization point for the output iterators
Added:
   sandbox/coerce/boost/coerce/sequence.hpp (contents, props changed)
Removed:
   sandbox/coerce/boost/coerce/detail/push_back.hpp
Text files modified:
   sandbox/coerce/boost/coerce/coerce.hpp | 4 ++--
   sandbox/coerce/boost/coerce/detail/karma.hpp | 5 +++--
   2 files changed, 5 insertions(+), 4 deletions(-)

Modified: sandbox/coerce/boost/coerce/coerce.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/coerce.hpp (original)
+++ sandbox/coerce/boost/coerce/coerce.hpp 2011-07-03 09:21:34 EDT (Sun, 03 Jul 2011)
@@ -12,7 +12,7 @@
 #endif
 
 #include <boost/coerce/detail/backend.hpp>
-#include <boost/coerce/detail/push_back.hpp>
+#include <boost/coerce/sequence.hpp>
 #include <boost/coerce/string.hpp>
 
 #include <boost/throw_exception.hpp>
@@ -26,7 +26,7 @@
         template <typename Target, typename Source, typename Enable = void>
         struct as
             : detail::backend<
- typename detail::is_back_insertion_sequence<Target>::type,
+ typename traits::is_sequence<Target>::type,
                 typename traits::is_string<Source>::type
>::type { };
 

Modified: sandbox/coerce/boost/coerce/detail/karma.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/detail/karma.hpp (original)
+++ sandbox/coerce/boost/coerce/detail/karma.hpp 2011-07-03 09:21:34 EDT (Sun, 03 Jul 2011)
@@ -12,6 +12,7 @@
 #endif
 
 #include <boost/coerce/reserve.hpp>
+#include <boost/coerce/sequence.hpp>
 
 #include <boost/spirit/home/karma/auto.hpp>
 #include <boost/spirit/home/karma/char.hpp>
@@ -19,7 +20,7 @@
 #include <boost/spirit/home/karma/operator/optional.hpp>
 #include <boost/spirit/include/version.hpp>
 
-#include <iterator> // std::back_inserter
+// #include <iterator> // std::back_inserter
 
 namespace boost { namespace coerce { namespace detail {
 
@@ -31,7 +32,7 @@
                 target, traits::reserve_size<Source>::call(source));
 
             bool result = spirit::karma::generate(
- std::back_inserter(target),
+ traits::sequence<Target>::back_inserter(target),
 #if SPIRIT_VERSION <= 0x2030
                 spirit::karma::auto_,
 #endif

Deleted: sandbox/coerce/boost/coerce/detail/push_back.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/detail/push_back.hpp 2011-07-03 09:21:34 EDT (Sun, 03 Jul 2011)
+++ (empty file)
@@ -1,56 +0,0 @@
-// Copyright Jeroen Habraken 2011.
-//
-// 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)
-
-#ifndef BOOST_COERCE_DETAIL_PUSH_BACK_HPP
-#define BOOST_COERCE_DETAIL_PUSH_BACK_HPP
-
-#ifdef _MSC_VER
-#pragma once
-#endif
-
-#include <boost/config.hpp>
-#include <boost/mpl/and.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/mpl/has_xxx.hpp>
-#include <boost/type_traits/detail/yes_no_type.hpp>
-
-namespace boost { namespace coerce { namespace detail {
-
- template <typename T>
- class has_push_back {
- template <typename U, void (U::*)(typename U::const_reference) = &U::push_back>
- struct const_reference { };
-
- template <typename U>
- static type_traits::yes_type test(U*, const_reference<U>* = 0);
-
- template <typename U, void (U::*)(typename U::value_type) = &U::push_back>
- struct value_type { };
-
- template <typename U>
- static type_traits::yes_type test(U*, value_type<U>* = 0);
-
- template <typename U>
- static type_traits::no_type test(...);
-
- public:
- BOOST_STATIC_CONSTANT(bool, value =
- sizeof(test<T>(0)) == sizeof(type_traits::yes_type));
- typedef mpl::bool_<value> type;
- };
-
- BOOST_MPL_HAS_XXX_TRAIT_DEF(const_reference)
-
- template <typename T>
- struct is_back_insertion_sequence
- : mpl::and_<
- has_push_back<T>,
- has_const_reference<T>
- > { };
-
-} } } // namespace boost::coerce::detail
-
-#endif // BOOST_COERCE_DETAIL_PUSH_BACK_HPP

Added: sandbox/coerce/boost/coerce/sequence.hpp
==============================================================================
--- (empty file)
+++ sandbox/coerce/boost/coerce/sequence.hpp 2011-07-03 09:21:34 EDT (Sun, 03 Jul 2011)
@@ -0,0 +1,56 @@
+// Copyright Jeroen Habraken 2011.
+//
+// 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)
+
+#ifndef BOOST_COERCE_SEQUENCE_HPP
+#define BOOST_COERCE_SEQUENCE_HPP
+
+#ifdef _MSC_VER
+#pragma once
+#endif
+
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+#include <iterator>
+#include <string>
+#include <vector>
+
+namespace boost { namespace coerce { namespace traits {
+
+ template <typename T>
+ struct sequence_impl
+ : mpl::identity<void> { };
+
+ template <typename T>
+ struct sequence_impl_std {
+ typedef T type;
+
+ static inline std::back_insert_iterator<type>
+ back_inserter(type & value) {
+ return std::back_inserter(value);
+ }
+ };
+
+ template <typename T, typename Traits, typename Allocator>
+ struct sequence_impl<std::basic_string<T, Traits, Allocator> >
+ : sequence_impl_std<std::basic_string<T, Traits, Allocator> > { };
+
+ template <typename T, typename Allocator>
+ struct sequence_impl<std::vector<T, Allocator> >
+ : sequence_impl_std<std::vector<T, Allocator> > { };
+
+ template <typename T, typename Enable = void>
+ struct sequence
+ : sequence_impl<T> { };
+
+ template <typename T>
+ struct is_sequence
+ : mpl::not_<is_same<typename sequence<T>::type, void> > { };
+
+} } } // namespace boost::coerce::traits
+
+#endif // BOOST_COERCE_SEQUENCE_HPP


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