|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77313 - in sandbox/coerce: boost/coerce boost/coerce/detail libs/coerce/test
From: vexocide_at_[hidden]
Date: 2012-03-12 07:57:43
Author: vexocide
Date: 2012-03-12 07:57:41 EDT (Mon, 12 Mar 2012)
New Revision: 77313
URL: http://svn.boost.org/trac/boost/changeset/77313
Log:
Added support for boost.range and moved implementation details into the detail namespace
Added:
sandbox/coerce/boost/coerce/tag_fwd.hpp (contents, props changed)
Text files modified:
sandbox/coerce/boost/coerce/coerce.hpp | 3 +--
sandbox/coerce/boost/coerce/detail/precision.hpp | 22 +++++++++++++++++++++-
sandbox/coerce/boost/coerce/reserve.hpp | 4 ++--
sandbox/coerce/boost/coerce/string.hpp | 22 ++++++++++++++++++++++
sandbox/coerce/boost/coerce/tag.hpp | 35 ++++-------------------------------
sandbox/coerce/libs/coerce/test/qi.cpp | 14 +++++++++++++-
6 files changed, 63 insertions(+), 37 deletions(-)
Modified: sandbox/coerce/boost/coerce/coerce.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/coerce.hpp (original)
+++ sandbox/coerce/boost/coerce/coerce.hpp 2012-03-12 07:57:41 EDT (Mon, 12 Mar 2012)
@@ -66,8 +66,7 @@
}
template <typename Target, typename Source, typename Tag>
- inline typename enable_if<
- detail::is_tag<Tag>, Target>::type
+ inline typename enable_if<detail::is_tag<Tag>, Target>::type
as_default(
Source const & source,
Tag const & tag,
Modified: sandbox/coerce/boost/coerce/detail/precision.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/detail/precision.hpp (original)
+++ sandbox/coerce/boost/coerce/detail/precision.hpp 2012-03-12 07:57:41 EDT (Mon, 12 Mar 2012)
@@ -1,4 +1,4 @@
-// Copyright Jeroen Habraken 2011.
+// Copyright Jeroen Habraken 2011 - 2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../../LICENSE_1_0.txt or copy at
@@ -13,6 +13,9 @@
#include <boost/config.hpp>
#include <boost/limits.hpp>
+#include <boost/spirit/home/karma/numeric/real.hpp>
+#include <boost/spirit/home/karma/numeric/real_policies.hpp>
+#include <boost/type_traits/remove_const.hpp>
namespace boost { namespace coerce { namespace detail {
@@ -40,6 +43,23 @@
: is_specialized_decimal ? precision_decimal : 6);
};
+ template <typename Source>
+ struct real_policies
+ : spirit::karma::real_policies<
+ typename remove_const<Source>::type
+ > {
+ static inline unsigned
+ precision(Source const &) {
+ return detail::precision<Source>::value;
+ }
+ };
+
+ template <typename Source>
+ struct real_generator
+ : spirit::karma::real_generator<
+ Source, detail::real_policies<Source>
+ > { };
+
} } } // namespace boost::coerce::detail
#endif // BOOST_COERCE_DETAIL_PRECISION_HPP
Modified: sandbox/coerce/boost/coerce/reserve.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/reserve.hpp (original)
+++ sandbox/coerce/boost/coerce/reserve.hpp 2012-03-12 07:57:41 EDT (Mon, 12 Mar 2012)
@@ -1,4 +1,4 @@
-// Copyright Jeroen Habraken 2010 - 2011.
+// Copyright Jeroen Habraken 2010 - 2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
@@ -13,7 +13,7 @@
#include <boost/coerce/detail/precision.hpp>
#include <boost/coerce/detail/reserve.hpp>
-#include <boost/coerce/tag.hpp>
+#include <boost/coerce/tag_fwd.hpp>
#include <boost/config.hpp>
#include <boost/integer/static_log2.hpp>
Modified: sandbox/coerce/boost/coerce/string.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/string.hpp (original)
+++ sandbox/coerce/boost/coerce/string.hpp 2012-03-12 07:57:41 EDT (Mon, 12 Mar 2012)
@@ -10,6 +10,7 @@
#include <boost/coerce/char.hpp>
#include <boost/mpl/bool.hpp>
+#include <boost/range/iterator_range_core.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <cstddef> // std::size_t
@@ -77,6 +78,23 @@
}
};
+ template <typename T>
+ struct string_traits_impl<boost::iterator_range<T> > {
+ typedef boost::iterator_range<T> type;
+
+ typedef typename type::const_iterator const_iterator;
+
+ static inline const_iterator
+ begin(type const & value) {
+ return value.begin();
+ }
+
+ static inline const_iterator
+ end(type const & value) {
+ return value.end();
+ }
+ };
+
template <typename T, typename Allocator>
struct string_traits_impl<std::vector<T, Allocator> > {
typedef std::vector<T, Allocator> type;
@@ -109,6 +127,10 @@
struct is_source_string_impl<std::basic_string<T, Traits, Allocator> >
: traits::is_char<T> { };
+ template <typename T>
+ struct is_source_string_impl<boost::iterator_range<T> >
+ : traits::is_char<typename boost::iterator_range<T>::value_type> { };
+
template <typename T, typename Enable = void>
struct is_source_string
: is_source_string_impl<T> { };
Modified: sandbox/coerce/boost/coerce/tag.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/tag.hpp (original)
+++ sandbox/coerce/boost/coerce/tag.hpp 2012-03-12 07:57:41 EDT (Mon, 12 Mar 2012)
@@ -1,4 +1,4 @@
-// Copyright Jeroen Habraken 2011.
+// Copyright Jeroen Habraken 2011 - 2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../LICENSE_1_0.txt or copy at
@@ -14,10 +14,7 @@
#include <boost/coerce/detail/precision.hpp>
#include <boost/spirit/home/karma/auto.hpp>
-#include <boost/spirit/home/karma/numeric/real.hpp>
-#include <boost/spirit/home/karma/numeric/real_policies.hpp>
#include <boost/spirit/home/qi/auto.hpp>
-#include <boost/type_traits/remove_const.hpp>
namespace boost { namespace coerce { namespace tag {
@@ -34,49 +31,25 @@
generator(tag::none const &) { }
};
- template <typename Source>
- struct real_policies
- : spirit::karma::real_policies<
- typename remove_const<Source>::type
- > {
- static inline unsigned
- precision(Source const &) {
- return detail::precision<Source>::value;
- }
- };
-
- template <typename Source>
- struct generator_floating_point
- : spirit::karma::real_generator<Source, real_policies<Source> > { };
-
template <typename Iterator, typename Target>
struct generator<Iterator, Target, float>
- : generator_floating_point<float> {
+ : detail::real_generator<float> {
generator(tag::none const &) { }
};
template <typename Iterator, typename Target>
struct generator<Iterator, Target, double>
- : generator_floating_point<double> {
+ : detail::real_generator<double> {
generator(tag::none const &) { }
};
template <typename Iterator, typename Target>
struct generator<Iterator, Target, long double>
- : generator_floating_point<long double> {
+ : detail::real_generator<long double> {
generator(tag::none const &) { }
};
};
- template <unsigned Radix>
- struct base;
-
- struct bin;
-
- struct oct;
-
- struct hex;
-
} } } // namespace boost::coerce::tag
#endif // BOOST_COERCE_TAG_HPP
Added: sandbox/coerce/boost/coerce/tag_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/coerce/boost/coerce/tag_fwd.hpp 2012-03-12 07:57:41 EDT (Mon, 12 Mar 2012)
@@ -0,0 +1,29 @@
+// Copyright Jeroen Habraken 2012.
+//
+// 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_TAG_FWD_HPP
+#define BOOST_COERCE_TAG_FWD_HPP
+
+#ifdef _MSC_VER
+#pragma once
+#endif
+
+namespace boost { namespace coerce { namespace tag {
+
+ struct none;
+
+ template <unsigned Radix>
+ struct base;
+
+ struct bin;
+
+ struct oct;
+
+ struct hex;
+
+} } } // namespace boost::coerce::tag
+
+#endif // BOOST_COERCE_TAG_FWD_HPP
Modified: sandbox/coerce/libs/coerce/test/qi.cpp
==============================================================================
--- sandbox/coerce/libs/coerce/test/qi.cpp (original)
+++ sandbox/coerce/libs/coerce/test/qi.cpp 2012-03-12 07:57:41 EDT (Mon, 12 Mar 2012)
@@ -1,4 +1,4 @@
-// Copyright Jeroen Habraken 2011.
+// Copyright Jeroen Habraken 2011 - 2012.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../../../LICENSE_1_0.txt or copy at
@@ -51,8 +51,20 @@
std::string string("1");
BOOST_CHECK_EQUAL(coerce::as<int>(string), 1);
+ BOOST_CHECK_EQUAL(coerce::as<int>(boost::make_iterator_range(string)), 1);
std::wstring wide_string(L"1");
BOOST_CHECK_EQUAL(coerce::as<int>(wide_string), 1);
+ BOOST_CHECK_EQUAL(coerce::as<int>(
+ boost::make_iterator_range(wide_string)), 1);
+
+ std::string const string_const("1");
+ BOOST_CHECK_EQUAL(coerce::as<int>(string_const), 1);
+ BOOST_CHECK_EQUAL(coerce::as<int>(
+ boost::make_iterator_range(string_const)), 1);
+ std::wstring const wide_string_const(L"1");
+ BOOST_CHECK_EQUAL(coerce::as<int>(wide_string_const), 1);
+ BOOST_CHECK_EQUAL(coerce::as<int>(
+ boost::make_iterator_range(wide_string_const)), 1);
BOOST_CHECK_EQUAL(coerce::as<int>(std::string("1")), 1);
BOOST_CHECK_EQUAL(coerce::as<int>(std::wstring(L"1")), 1);
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