Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71644 - in sandbox/coerce: boost boost/coerce libs/coerce/test
From: vexocide_at_[hidden]
Date: 2011-05-01 04:43:35


Author: vexocide
Date: 2011-05-01 04:43:33 EDT (Sun, 01 May 2011)
New Revision: 71644
URL: http://svn.boost.org/trac/boost/changeset/71644

Log:
Use boost::range instead of iterable
Removed:
   sandbox/coerce/boost/coerce/iterable.hpp
   sandbox/coerce/libs/coerce/test/iterable.cpp
Text files modified:
   sandbox/coerce/boost/coerce.hpp | 26 +++++++++++++-------------
   sandbox/coerce/libs/coerce/test/Jamfile.v2 | 3 ---
   2 files changed, 13 insertions(+), 16 deletions(-)

Modified: sandbox/coerce/boost/coerce.hpp
==============================================================================
--- sandbox/coerce/boost/coerce.hpp (original)
+++ sandbox/coerce/boost/coerce.hpp 2011-05-01 04:43:33 EDT (Sun, 01 May 2011)
@@ -6,10 +6,14 @@
 #define BOOST_COERCE_HPP
 
 #include <boost/coerce/container.hpp>
-#include <boost/coerce/iterable.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>
@@ -18,11 +22,8 @@
 #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/home/support/unused.hpp>
 #include <boost/spirit/include/version.hpp>
 #include <boost/static_assert.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/utility/enable_if.hpp>
 
 #include <typeinfo> // for std::bad_cast
 
@@ -42,7 +43,7 @@
                     return do_call(
                         target,
                         source,
- traits::is_iterable<Source>(),
+ has_range_const_iterator<Source>(),
                         traits::is_container<Target>());
                 }
 
@@ -54,18 +55,17 @@
                         mpl::true_,
                         bool
                     ) {
- typedef traits::iterable<Source> iterable_type;
- typedef typename iterable_type::const_iterator iterator_type;
+ typedef typename range_const_iterator<Source>::type iterator_type;
 
- iterable_type iterable(source);
-
- if (iterable.size() < 1)
+ typename range_difference<Source>::type size;
+ if ((size = boost::size(source)) < 1)
                             return false;
 
- call_reserve(target, iterable.size());
+ call_reserve(target, size);
 
- iterator_type begin = iterable.begin(), iterator = begin;
- iterator_type end = iterable.end();
+ iterator_type begin = const_begin(source),
+ iterator = begin;
+ iterator_type end = const_end(source);
 
                         bool result = spirit::qi::parse(
                             iterator, end, target);

Deleted: sandbox/coerce/boost/coerce/iterable.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/iterable.hpp 2011-05-01 04:43:33 EDT (Sun, 01 May 2011)
+++ (empty file)
@@ -1,272 +0,0 @@
-// Copyright Jeroen Habraken 2010.
-//
-// 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_ITERABLE_HPP
-#define BOOST_COERCE_ITERABLE_HPP
-
-#include <boost/mpl/identity.hpp>
-#include <boost/mpl/not.hpp>
-#include <boost/optional.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/type_traits/remove_const.hpp>
-#include <boost/type_traits/remove_reference.hpp>
-
-#include <cstddef>
-#include <cstring>
-#include <cwchar>
-#include <string>
-
-namespace boost {
-
- namespace coerce {
-
- namespace traits {
-
- struct not_iterable { };
-
- template <typename Type>
- struct iterable_impl
- : mpl::identity<not_iterable> { };
-
- template <>
- struct iterable_impl<char const *> {
- typedef char const * type;
-
- typedef char * iterator;
- typedef char const * const_iterator;
-
- typedef std::size_t size_type;
-
- iterable_impl(type const & value)
- : value_(value) { }
-
- inline const_iterator
- begin() {
- return value_;
- }
-
- inline const_iterator
- end() {
- return value_ + size();
- }
-
- inline size_type
- size() {
- if (!size_)
- size_ = strlen(value_);
-
- return size_.get();
- }
-
- private:
- type const value_;
-
- optional<size_type> mutable size_;
- };
-
- template <>
- struct iterable_impl<char *>
- : iterable_impl<char const *> {
- typedef char * type;
-
- iterable_impl(type const & value)
- : iterable_impl<char const *>(value) { }
- };
-
- template <>
- struct iterable_impl<wchar_t const *> {
- typedef wchar_t const * type;
-
- typedef wchar_t * iterator;
- typedef wchar_t const * const_iterator;
-
- typedef std::size_t size_type;
-
- iterable_impl(type const & value)
- : value_(value) { }
-
- inline const_iterator
- begin() {
- return value_;
- }
-
- inline const_iterator
- end() {
- return value_ + size();
- }
-
- inline size_type
- size() {
- if (!size_)
- size_ = wcslen(value_);
-
- return size_.get();
- }
-
- private:
- type const value_;
-
- optional<size_type> mutable size_;
- };
-
- template <>
- struct iterable_impl<wchar_t *>
- : iterable_impl<wchar_t const *> {
- typedef wchar_t * type;
-
- iterable_impl(type const & value)
- : iterable_impl<wchar_t const *>(value) { }
- };
-
- template <typename CharT, std::size_t N>
- struct iterable_impl_extent {
- typedef CharT type[N];
-
- typedef CharT * iterator;
- typedef CharT const * const_iterator;
-
- typedef std::size_t size_type;
-
- iterable_impl_extent(CharT const (& value)[N])
- : value_(value) { }
-
- inline const_iterator
- begin() {
- return &value_[0];
- }
-
- inline const_iterator
- end() {
- return &value_[0] + size();
- }
-
- inline size_type
- size() {
- return value_[N - 1] == 0 ? N - 1 : N;
- }
-
- private:
- CharT const (& value_)[N];
- };
-
- template <std::size_t N>
- struct iterable_impl<char [N]>
- : iterable_impl_extent<char, N> {
- iterable_impl(char const (& value)[N])
- : iterable_impl_extent<char, N>(value) { }
- };
-
- template <std::size_t N>
- struct iterable_impl<wchar_t [N]>
- : iterable_impl_extent<wchar_t, N> {
- iterable_impl(wchar_t const (& value)[N])
- : iterable_impl_extent<wchar_t, N>(value) { }
- };
-
- template <typename CharT, typename Traits, typename Allocator>
- struct iterable_impl<std::basic_string<CharT, Traits, Allocator> > {
- typedef std::basic_string<CharT, Traits, Allocator> type;
-
- typedef typename type::iterator iterator;
- typedef typename type::const_iterator const_iterator;
-
- typedef typename type::size_type size_type;
-
- iterable_impl(type const & value)
- : value_(value) { }
-
- inline const_iterator
- begin() {
- return value_.begin();
- }
-
- inline const_iterator
- end() {
- return value_.end();
- }
-
- inline size_type
- size() {
- return value_.size();
- }
-
- private:
- type const & value_;
- };
-
-#ifdef BOOST_COERCE_ITERABLE_CHARACTER
-
- template <typename CharT>
- struct iterable_impl_char {
- typedef CharT type;
-
- typedef CharT * iterator;
- typedef CharT const * const_iterator;
-
- typedef std::size_t size_type;
-
- iterable_impl_char(CharT const & value)
- : value_(value) { }
-
- inline const_iterator
- begin() {
- return &value_;
- }
-
- inline const_iterator
- end() {
- return &value_ + size();
- }
-
- inline size_type
- size() {
- return value_ == 0 ? 0 : 1;
- }
-
- private:
- CharT const & value_;
- };
-
- template <>
- struct iterable_impl<char>
- : iterable_impl_char<char> {
- iterable_impl(char const & value)
- : iterable_impl_char<char>(value) { }
- };
-
- template <>
- struct iterable_impl<wchar_t>
- : iterable_impl_char<wchar_t> {
- iterable_impl(wchar_t const & value)
- : iterable_impl_char<wchar_t>(value) { }
- };
-
-#endif // BOOST_COERCE_ITERABLE_CHARACTER
-
- template <typename Type, typename Enable = void>
- struct iterable
- : iterable_impl<
- typename remove_const<
- typename remove_reference<Type>::type
- >::type> {
- iterable(typename iterable<Type>::type const & value)
- : iterable_impl<typename iterable<Type>::type>(value) { }
- };
-
- template <typename Type>
- struct is_iterable
- : mpl::not_<is_same<
- typename iterable<Type>::type,
- not_iterable
- > > { };
-
- } // namespace traits
-
- } // namespace coerce
-
-} // namespace boost
-
-#endif // BOOST_COERCE_ITERABLE_HPP

Modified: sandbox/coerce/libs/coerce/test/Jamfile.v2
==============================================================================
--- sandbox/coerce/libs/coerce/test/Jamfile.v2 (original)
+++ sandbox/coerce/libs/coerce/test/Jamfile.v2 2011-05-01 04:43:33 EDT (Sun, 01 May 2011)
@@ -10,8 +10,5 @@
         <source>/boost//unit_test_framework
     ;
 
-unit-test iterable :
- iterable.cpp ;
-
 unit-test reserve :
     reserve.cpp ;

Deleted: sandbox/coerce/libs/coerce/test/iterable.cpp
==============================================================================
--- sandbox/coerce/libs/coerce/test/iterable.cpp 2011-05-01 04:43:33 EDT (Sun, 01 May 2011)
+++ (empty file)
@@ -1,92 +0,0 @@
-// Copyright Jeroen Habraken 2010.
-//
-// 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)
-
-#define BOOST_TEST_MODULE iterable
-
-#include <boost/coerce.hpp>
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-
-BOOST_TEST_DONT_PRINT_LOG_VALUE(std::string::const_iterator)
-
-BOOST_AUTO_TEST_CASE(iterable) {
- using boost::coerce::traits::iterable;
-
- char const * test_char_const_pointer = "test";
- iterable<char const *> test_iterable_char_const_pointer(
- test_char_const_pointer);
- BOOST_CHECK_EQUAL(
- test_iterable_char_const_pointer.begin(),
- &test_char_const_pointer[0]);
- BOOST_CHECK_EQUAL(
- test_iterable_char_const_pointer.end(),
- &test_char_const_pointer[0] + 4);
- BOOST_CHECK_EQUAL(test_iterable_char_const_pointer.size(), 4u);
-
- wchar_t const * test_wchar_t_const_pointer = L"test";
- iterable<wchar_t const *> test_iterable_wchar_t_const_pointer(
- test_wchar_t_const_pointer);
- BOOST_CHECK_EQUAL(
- test_iterable_wchar_t_const_pointer.begin(),
- &test_wchar_t_const_pointer[0]);
- BOOST_CHECK_EQUAL(
- test_iterable_wchar_t_const_pointer.end(),
- &test_wchar_t_const_pointer[0] + 4);
- BOOST_CHECK_EQUAL(test_iterable_wchar_t_const_pointer.size(), 4u);
-
- char const test_char_const_extend[5] = "test";
- iterable<char const *> test_iterable_char_const_extend(
- test_char_const_extend);
- BOOST_CHECK_EQUAL(
- test_iterable_char_const_extend.begin(), &test_char_const_extend[0]);
- BOOST_CHECK_EQUAL(
- test_iterable_char_const_extend.end(), &test_char_const_extend[0] + 4);
- BOOST_CHECK_EQUAL(test_iterable_char_const_extend.size(), 4u);
-
- std::string const test_string_const("test");
- iterable<std::string const> test_iterable_string_const(test_string_const);
- BOOST_CHECK_EQUAL(
- test_iterable_string_const.begin(), test_string_const.begin());
- BOOST_CHECK_EQUAL(
- test_iterable_string_const.end(), test_string_const.end());
- BOOST_CHECK_EQUAL(
- test_iterable_string_const.size(), 4u);
-}
-
-BOOST_AUTO_TEST_CASE(is_iterable) {
- using boost::coerce::traits::is_iterable;
-
- BOOST_CHECK(!is_iterable<bool>::type());
-
- BOOST_CHECK(is_iterable<char *>::type());
- BOOST_CHECK(is_iterable<char const *>::type());
- BOOST_CHECK(is_iterable<char * const>::type());
- BOOST_CHECK(is_iterable<char const * const>::type());
- BOOST_CHECK(is_iterable<char [1]>::type());
- BOOST_CHECK(is_iterable<char const [1]>::type());
- BOOST_CHECK(is_iterable<char (&)[1]>::type());
- BOOST_CHECK(is_iterable<char const (&)[1]>::type());
-
- BOOST_CHECK(is_iterable<wchar_t *>::type());
- BOOST_CHECK(is_iterable<wchar_t const *>::type());
- BOOST_CHECK(is_iterable<wchar_t * const>::type());
- BOOST_CHECK(is_iterable<wchar_t const * const>::type());
- BOOST_CHECK(is_iterable<wchar_t [1]>::type());
- BOOST_CHECK(is_iterable<wchar_t const [1]>::type());
- BOOST_CHECK(is_iterable<wchar_t (&)[1]>::type());
- BOOST_CHECK(is_iterable<wchar_t const (&)[1]>::type());
-
- BOOST_CHECK(is_iterable<std::string>::type());
- BOOST_CHECK(is_iterable<std::string const>::type());
- BOOST_CHECK(is_iterable<std::string &>::type());
- BOOST_CHECK(is_iterable<std::string const &>::type());
-
- BOOST_CHECK(is_iterable<std::wstring>::type());
- BOOST_CHECK(is_iterable<std::wstring const>::type());
- BOOST_CHECK(is_iterable<std::wstring &>::type());
- BOOST_CHECK(is_iterable<std::wstring const &>::type());
-}


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