Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71699 - in sandbox/coerce/boost: . coerce
From: vexocide_at_[hidden]
Date: 2011-05-03 14:32:12


Author: vexocide
Date: 2011-05-03 14:32:11 EDT (Tue, 03 May 2011)
New Revision: 71699
URL: http://svn.boost.org/trac/boost/changeset/71699

Log:
Fixed a bug disallowing empty input, moved coerce.hpp and fixed copyrights
Added:
   sandbox/coerce/boost/coerce/coerce.hpp
      - copied, changed from r71644, /sandbox/coerce/boost/coerce.hpp
Removed:
   sandbox/coerce/boost/coerce.hpp
Text files modified:
   sandbox/coerce/boost/coerce/coerce.hpp | 13 +++++++------
   sandbox/coerce/boost/coerce/container.hpp | 2 +-
   sandbox/coerce/boost/coerce/reserve.hpp | 2 +-
   3 files changed, 9 insertions(+), 8 deletions(-)

Deleted: sandbox/coerce/boost/coerce.hpp
==============================================================================
--- sandbox/coerce/boost/coerce.hpp 2011-05-03 14:32:11 EDT (Tue, 03 May 2011)
+++ (empty file)
@@ -1,160 +0,0 @@
-// 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_HPP
-#define BOOST_COERCE_HPP
-
-#include <boost/coerce/container.hpp>
-#include <boost/coerce/reserve.hpp>
-
-#include <boost/mpl/bool.hpp>
-#include <boost/range/begin.hpp>
-#include <boost/range/const_iterator.hpp>
-#include <boost/range/end.hpp>
-#include <boost/range/has_range_iterator.hpp>
-#include <boost/range/size.hpp>
-#include <boost/spirit/home/karma/auto.hpp>
-#include <boost/spirit/home/karma/char.hpp>
-#include <boost/spirit/home/karma/numeric.hpp>
-#include <boost/spirit/home/karma/operator/optional.hpp>
-#include <boost/spirit/home/qi/auto.hpp>
-#include <boost/spirit/home/qi/char.hpp>
-#include <boost/spirit/home/qi/numeric.hpp>
-#include <boost/spirit/home/qi/operator/optional.hpp>
-#include <boost/spirit/include/version.hpp>
-#include <boost/static_assert.hpp>
-
-#include <typeinfo> // for std::bad_cast
-
-namespace boost {
-
- namespace coerce {
-
- class bad_cast
- : public std::bad_cast { };
-
- namespace detail {
-
- template <typename Target, typename Source>
- struct as {
- static inline bool
- call(Target & target, Source const & source) {
- return do_call(
- target,
- source,
- has_range_const_iterator<Source>(),
- traits::is_container<Target>());
- }
-
- private:
- static inline bool
- do_call(
- Target & target,
- Source const & source,
- mpl::true_,
- bool
- ) {
- typedef typename range_const_iterator<Source>::type iterator_type;
-
- typename range_difference<Source>::type size;
- if ((size = boost::size(source)) < 1)
- return false;
-
- call_reserve(target, size);
-
- iterator_type begin = const_begin(source),
- iterator = begin;
- iterator_type end = const_end(source);
-
- bool result = spirit::qi::parse(
- iterator, end, target);
-
- if (!result || !((begin < iterator && iterator < end && *iterator == 0) || iterator == end))
- return false;
-
- return true;
- }
-
- static inline bool
- do_call(
- Target & target,
- Source const & source,
- mpl::false_,
- mpl::true_
- ) {
- call_reserve(
- target,
- traits::reserve_size<Source>::call(source));
-
- bool result = spirit::karma::generate(
- std::back_inserter(target),
-#if SPIRIT_VERSION <= 0x2030
- spirit::karma::auto_,
-#endif
- source);
-
- return result;
- }
-
- static inline bool
- do_call(
- Target & target,
- Source const & source,
- mpl::false_,
- mpl::false_
- ) {
- BOOST_STATIC_ASSERT(sizeof(Target) == 0);
-
- return false;
- }
- };
-
- } // namespace detail
-
- namespace traits {
-
- template <typename Target, typename Source, typename Enable = void>
- struct as
- : coerce::detail::as<Target, Source> { };
-
- } // namespace traits
-
- template <typename Target, typename Source>
- inline Target
- as(Source const & source) {
- Target target;
-
- bool result = traits::as<
- Target, Source
- >::call(target, source);
-
- if (!result)
- throw coerce::bad_cast();
-
- return target;
- }
-
- template <typename Target, typename Source>
- inline Target
- as_default(
- Source const & source,
- Target const & default_value = Target()
- ) {
- Target target;
-
- bool result = traits::as<
- Target, Source
- >::call(target, source);
-
- if (!result)
- return default_value;
-
- return target;
- }
-
- } // namespace coerce
-
-} // namespace boost
-
-#endif // BOOST_COERCE_HPP

Copied: sandbox/coerce/boost/coerce/coerce.hpp (from r71644, /sandbox/coerce/boost/coerce.hpp)
==============================================================================
--- /sandbox/coerce/boost/coerce.hpp (original)
+++ sandbox/coerce/boost/coerce/coerce.hpp 2011-05-03 14:32:11 EDT (Tue, 03 May 2011)
@@ -1,9 +1,11 @@
+// Copyright Jeroen Habraken 2010 - 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_HPP
-#define BOOST_COERCE_HPP
+#ifndef BOOST_COERCE_COERCE_HPP
+#define BOOST_COERCE_COERCE_HPP
 
 #include <boost/coerce/container.hpp>
 #include <boost/coerce/reserve.hpp>
@@ -58,8 +60,7 @@
                         typedef typename range_const_iterator<Source>::type iterator_type;
 
                         typename range_difference<Source>::type size;
- if ((size = boost::size(source)) < 1)
- return false;
+ size = boost::size(source);
 
                         call_reserve(target, size);
 
@@ -70,7 +71,7 @@
                         bool result = spirit::qi::parse(
                             iterator, end, target);
 
- if (!result || !((begin < iterator && iterator < end && *iterator == 0) || iterator == end))
+ if (!result || !((begin <= iterator && iterator < end && *iterator == 0) || iterator == end))
                             return false;
 
                         return true;
@@ -157,4 +158,4 @@
 
 } // namespace boost
 
-#endif // BOOST_COERCE_HPP
+#endif // BOOST_COERCE_COERCE_HPP

Modified: sandbox/coerce/boost/coerce/container.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/container.hpp (original)
+++ sandbox/coerce/boost/coerce/container.hpp 2011-05-03 14:32:11 EDT (Tue, 03 May 2011)
@@ -1,4 +1,4 @@
-// Copyright Jeroen Habraken 2010.
+// Copyright Jeroen Habraken 2010 - 2011.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file ../../../LICENSE_1_0.txt or copy at

Modified: sandbox/coerce/boost/coerce/reserve.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/reserve.hpp (original)
+++ sandbox/coerce/boost/coerce/reserve.hpp 2011-05-03 14:32:11 EDT (Tue, 03 May 2011)
@@ -1,5 +1,5 @@
 // Copyright Adam Merz 2010.
-// Copyright Jeroen Habraken 2010.
+// Copyright Jeroen Habraken 2010 - 2011.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file ../../../LICENSE_1_0.txt or copy at


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