mirror of
https://github.com/boostorg/range.git
synced 2025-07-01 23:11:06 +02:00
Compare commits
53 Commits
boost-1.55
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
b4ed5cbc2d | |||
34cea300e5 | |||
cca9739022 | |||
30e6df5a15 | |||
2285f909f6 | |||
0addcfadeb | |||
426e0c39a8 | |||
f662a07bcc | |||
90ce7f3703 | |||
a59819fc6e | |||
2480b52f5b | |||
b4f00e3c18 | |||
b0c1cf556f | |||
8be23dd1aa | |||
1eb5554da9 | |||
3d3631744f | |||
991bd7f8be | |||
c908e04144 | |||
1c18f42e83 | |||
fe79a8efdd | |||
4971da58ee | |||
45a1acb980 | |||
f228ab608a | |||
cbd915a988 | |||
fc88bc06ad | |||
4a44cc75c9 | |||
86b169dab3 | |||
36843ccdba | |||
17e4f7024d | |||
3379affd4a | |||
958b4fbf6e | |||
61979ff421 | |||
1d51c3afb2 | |||
b7f443e583 | |||
f49e347772 | |||
bf4ca510ea | |||
665c4a3234 | |||
dceccc9de9 | |||
a72eae6099 | |||
5a04c9e05b | |||
e6279d4436 | |||
11238e4c19 | |||
1cb6a99c80 | |||
c4bd4bf4ce | |||
41b76f8f5c | |||
846f11a96c | |||
8810c4c4aa | |||
91428c2110 | |||
44c26a3356 | |||
b06fca8378 | |||
3b3889b70f | |||
5ed6116490 | |||
df1a3a334f |
@ -15,7 +15,7 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if _MSC_VER == 1300 // experiment
|
||||
#if defined(_MSC_VER) && (_MSC_VER == 1300)
|
||||
|
||||
#include <boost/range/detail/collection_traits.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
@ -28,6 +28,6 @@
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/sub_range.hpp>
|
||||
|
||||
#endif // _MSC_VER == 1300 // experiment
|
||||
#endif // _MSC_VER == 1300
|
||||
|
||||
#endif
|
||||
|
@ -52,9 +52,9 @@ namespace boost
|
||||
template< class T, class U, class V >
|
||||
struct regex_holder
|
||||
{
|
||||
const T& re;
|
||||
const U& sub;
|
||||
V f;
|
||||
T re;
|
||||
U sub;
|
||||
V f;
|
||||
|
||||
regex_holder( const T& rex, const U& subm, V flag ) :
|
||||
re(rex), sub(subm), f(flag)
|
||||
|
@ -89,11 +89,11 @@ inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange, return_begin_found>::ty
|
||||
unique( ForwardRange& rng, BinaryPredicate pred )
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
|
||||
return ::boost::range::unique<return_begin_found>(rng);
|
||||
return ::boost::range::unique<return_begin_found>(rng, pred);
|
||||
}
|
||||
/// \overload
|
||||
template< class ForwardRange, class BinaryPredicate >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange, return_begin_found>::type
|
||||
unique( const ForwardRange& rng, BinaryPredicate pred )
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
|
||||
|
@ -48,6 +48,12 @@
|
||||
#define BOOST_RANGE_ARRAY_REF() (&boost_range_array)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
|
||||
# define BOOST_RANGE_UNUSED __attribute__((unused))
|
||||
#else
|
||||
# define BOOST_RANGE_UNUSED
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -21,13 +21,13 @@
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
template <typename T>
|
||||
inline void boost_range_silence_warning( const T& ) { }
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// end() help
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -36,7 +36,7 @@ namespace boost
|
||||
{
|
||||
return s + strlen( s );
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
|
||||
{
|
||||
@ -51,7 +51,7 @@ namespace boost
|
||||
;
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template< class Char >
|
||||
inline Char* str_end( Char* s )
|
||||
@ -64,7 +64,7 @@ namespace boost
|
||||
{
|
||||
return boost_range_array + sz;
|
||||
}
|
||||
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
@ -74,7 +74,7 @@ namespace boost
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// size() help
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
template< class Char >
|
||||
inline std::size_t str_size( const Char* const& s )
|
||||
{
|
||||
@ -96,7 +96,7 @@ namespace boost
|
||||
}
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
|
@ -23,6 +23,10 @@
|
||||
#include <boost/range/empty.hpp>
|
||||
#include <boost/range/detail/demote_iterator_traversal_tag.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
namespace boost
|
||||
@ -71,7 +75,9 @@ public:
|
||||
|
||||
Reference dereference(unsigned int selected) const
|
||||
{
|
||||
return selected ? *m_it2 : *m_it1;
|
||||
if (selected)
|
||||
return *m_it2;
|
||||
return *m_it1;
|
||||
}
|
||||
|
||||
bool equal(const join_iterator_union& other, unsigned int selected) const
|
||||
@ -144,7 +150,7 @@ template<typename Iterator1
|
||||
>::type
|
||||
>::value,
|
||||
typename add_const<
|
||||
typename iterator_reference<Iterator2>::type
|
||||
typename iterator_reference<Iterator1>::type
|
||||
>::type,
|
||||
typename iterator_reference<Iterator1>::type
|
||||
>::type
|
||||
|
@ -168,7 +168,7 @@ namespace boost
|
||||
typedef boost::iterator_range<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
|
||||
|
||||
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
|
||||
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type,
|
||||
SinglePassRange& rng)
|
||||
{
|
||||
return type(boost::begin(rng), boost::end(rng));
|
||||
|
@ -7,10 +7,14 @@
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
// Acknowledgments:
|
||||
// Ticket #8341: Arno Schoedl - improved handling of has_range_iterator upon
|
||||
// use-cases where T was const.
|
||||
#ifndef BOOST_RANGE_HAS_ITERATOR_HPP_INCLUDED
|
||||
#define BOOST_RANGE_HAS_ITERATOR_HPP_INCLUDED
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
@ -28,7 +32,16 @@ namespace boost
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct has_range_iterator_impl<T, BOOST_DEDUCED_TYPENAME enable_if< has_type< range_mutable_iterator<T> > >::type>
|
||||
struct has_range_iterator_impl<
|
||||
T,
|
||||
BOOST_DEDUCED_TYPENAME enable_if<
|
||||
BOOST_DEDUCED_TYPENAME mpl::eval_if<is_const<T>,
|
||||
has_type<range_const_iterator<
|
||||
BOOST_DEDUCED_TYPENAME remove_const<T>::type> >,
|
||||
has_type<range_mutable_iterator<T> >
|
||||
>::type
|
||||
>::type
|
||||
>
|
||||
: boost::mpl::true_
|
||||
{
|
||||
};
|
||||
@ -40,7 +53,12 @@ namespace boost
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct has_range_const_iterator_impl<T, BOOST_DEDUCED_TYPENAME enable_if< has_type< range_const_iterator<T> > >::type>
|
||||
struct has_range_const_iterator_impl<
|
||||
T,
|
||||
BOOST_DEDUCED_TYPENAME enable_if<
|
||||
has_type<range_const_iterator<T> >
|
||||
>::type
|
||||
>
|
||||
: boost::mpl::true_
|
||||
{
|
||||
};
|
||||
|
@ -25,46 +25,46 @@
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
namespace range_detail_vc7_1
|
||||
{
|
||||
template< typename C, typename Sig = void(C) >
|
||||
struct range_iterator
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
};
|
||||
|
||||
template< typename C, typename T >
|
||||
struct range_iterator< C, void(T[]) >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
namespace range_detail_vc7_1
|
||||
{
|
||||
template< typename C, typename Sig = void(C) >
|
||||
struct range_iterator
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
};
|
||||
|
||||
template< typename C, typename T >
|
||||
struct range_iterator< C, void(T[]) >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template< typename C >
|
||||
struct range_iterator
|
||||
{
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail_vc7_1::range_iterator<C>::type type;
|
||||
|
||||
#else
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail_vc7_1::range_iterator<C>::type type;
|
||||
|
||||
#else
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/range/detail/size_type.hpp>
|
||||
#else
|
||||
@ -45,8 +46,8 @@ namespace boost
|
||||
template<typename C>
|
||||
static yes_type test(BOOST_DEDUCED_TYPENAME C::size_type x);
|
||||
|
||||
template<typename C, typename Arg>
|
||||
static no_type test(Arg x);
|
||||
template<typename C>
|
||||
static no_type test(...);
|
||||
|
||||
public:
|
||||
static const bool value = sizeof(test<T>(0)) == sizeof(yes_type);
|
||||
@ -74,12 +75,24 @@ namespace boost
|
||||
template< class T >
|
||||
struct range_size :
|
||||
detail::range_size<T>
|
||||
{ };
|
||||
{
|
||||
// Very strange things happen on some compilers that have the range concept
|
||||
// asserts disabled. This preprocessor condition is clearly redundant on a
|
||||
// working compiler but is vital for at least some compilers such as clang 4.2
|
||||
// but only on the Mac!
|
||||
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT == 1
|
||||
BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<T>));
|
||||
#endif
|
||||
};
|
||||
|
||||
template< class T >
|
||||
struct range_size<const T >
|
||||
: detail::range_size<T>
|
||||
{ };
|
||||
{
|
||||
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT == 1
|
||||
BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<T>));
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
//
|
||||
#include <boost/range/adaptor/strided.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
@ -42,9 +43,12 @@ namespace boost
|
||||
Container reference;
|
||||
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::const_iterator iterator_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::difference_type diff_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::size_type size_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::const_iterator
|
||||
iterator_t BOOST_RANGE_UNUSED;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::difference_type
|
||||
diff_t BOOST_RANGE_UNUSED;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::size_type
|
||||
size_type BOOST_RANGE_UNUSED;
|
||||
iterator_t it = c.begin();
|
||||
|
||||
iterator_t last = c.end();
|
||||
@ -128,6 +132,7 @@ namespace boost
|
||||
|
||||
typedef boost::strided_range<Container> strided_range_t;
|
||||
strided_range_t rng( boost::adaptors::stride(c, 0) );
|
||||
boost::ignore_unused_variable_warning(rng);
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_iterator<strided_range_t>::type iter_t;
|
||||
|
||||
iter_t first(boost::begin(c), boost::begin(c), boost::end(c), 0);
|
||||
|
@ -35,6 +35,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/range/numeric.hpp>
|
||||
@ -107,9 +108,11 @@ void test_random_algorithms(Rng & rng, std::random_access_iterator_tag)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_iterator<Rng>::type iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_value<Rng>::type value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_size<Rng>::type size_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_size<Rng>::type size_type BOOST_RANGE_UNUSED;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_category<iterator>::type iterator_category;
|
||||
|
||||
|
||||
|
||||
// just make sure these compile (for now)
|
||||
if(0)
|
||||
{
|
||||
@ -328,6 +331,8 @@ void test_algorithms(Rng & rng)
|
||||
o = boost::adjacent_difference( rng, boost::begin(out) );
|
||||
o = boost::adjacent_difference( rng, boost::begin(out),
|
||||
null_op2() );
|
||||
|
||||
boost::ignore_unused_variable_warning(b);
|
||||
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace boost
|
||||
source.begin(), source.end()
|
||||
);
|
||||
|
||||
it == boost::copy(boost::make_iterator_range(source), target.begin());
|
||||
it = boost::copy(boost::make_iterator_range(source), target.begin());
|
||||
|
||||
BOOST_CHECK( it == target.end() );
|
||||
|
||||
|
@ -71,6 +71,8 @@ namespace boost_range_test_algorithm_stable_partition
|
||||
|
||||
result_t result2 = boost::stable_partition<return_type>(
|
||||
boost::make_iterator_range(cont2), policy.pred());
|
||||
|
||||
boost::ignore_unused_variable_warning(result2);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS( cont2.begin(), cont2.end(),
|
||||
cont.begin(), cont.end() );
|
||||
|
@ -41,6 +41,8 @@ namespace boost
|
||||
|
||||
iterator_t reference_it
|
||||
= std::transform(cont.begin(), cont.end(), reference.begin(), fn);
|
||||
|
||||
boost::ignore_unused_variable_warning(reference_it);
|
||||
|
||||
iterator_t test_it
|
||||
= boost::transform(cont, target.begin(), fn);
|
||||
@ -101,6 +103,8 @@ namespace boost
|
||||
iterator_t reference_it
|
||||
= std::transform(cont1.begin(), cont1.end(),
|
||||
cont2.begin(), reference.begin(), fn);
|
||||
|
||||
boost::ignore_unused_variable_warning(reference_it);
|
||||
|
||||
iterator_t test_it
|
||||
= boost::transform(cont1, cont2, target.begin(), fn);
|
||||
|
@ -9,13 +9,15 @@
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#include <boost/range/algorithm/unique.hpp>
|
||||
#include <boost/range/detail/range_return.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include "../test_driver/range_return_test_driver.hpp"
|
||||
#include <boost/config.hpp>
|
||||
#include "../test_driver/range_overload_test_driver.hpp"
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
@ -60,6 +62,36 @@ namespace boost_range_test_algorithm_unique
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Container>
|
||||
struct test_range_overload
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
::boost::range_return_value,
|
||||
result_type = ::boost::return_begin_found);
|
||||
|
||||
template<typename Policy>
|
||||
BOOST_DEDUCED_TYPENAME boost::range_return<
|
||||
Container, result_type
|
||||
>::type
|
||||
operator()(Policy& policy, Container& cont)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_return<
|
||||
Container,result_type>::type result_t;
|
||||
|
||||
Container cont2(cont);
|
||||
|
||||
result_t result = boost::unique(cont);
|
||||
|
||||
boost::unique(boost::make_iterator_range(cont2));
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||
cont.begin(), cont.end(),
|
||||
cont2.begin(), cont2.end());
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template< class Container >
|
||||
BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type
|
||||
reference(Container& cont)
|
||||
@ -67,7 +99,7 @@ namespace boost_range_test_algorithm_unique
|
||||
return std::unique(cont.begin(), cont.end());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// test the 'unique' algorithm with a predicate
|
||||
template<class Pred>
|
||||
class unique_pred_test_policy
|
||||
@ -105,6 +137,34 @@ namespace boost_range_test_algorithm_unique
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Container>
|
||||
struct test_range_overload
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
::boost::range_return_value,
|
||||
result_type = ::boost::return_begin_found);
|
||||
|
||||
template<typename Policy>
|
||||
BOOST_DEDUCED_TYPENAME boost::range_return<Container,result_type>::type
|
||||
operator()(Policy& policy, Container& cont)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_return<
|
||||
Container,result_type>::type result_t;
|
||||
|
||||
Container cont2(cont);
|
||||
|
||||
result_t result = boost::unique(cont, policy.pred());
|
||||
|
||||
boost::unique(boost::make_iterator_range(cont2), policy.pred());
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(
|
||||
cont.begin(), cont.end(),
|
||||
cont2.begin(), cont2.end());
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template< class Container >
|
||||
BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type
|
||||
@ -121,7 +181,7 @@ namespace boost_range_test_algorithm_unique
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::value_type value_t;
|
||||
|
||||
boost::range_test::range_return_test_driver test_driver;
|
||||
boost::range_test::range_overload_test_driver test_driver;
|
||||
|
||||
Container cont;
|
||||
|
||||
@ -145,6 +205,19 @@ namespace boost_range_test_algorithm_unique
|
||||
|
||||
test_driver(cont, policy);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct equal_div_2
|
||||
{
|
||||
typedef bool result_type;
|
||||
typedef const T& first_argument_type;
|
||||
typedef const T& second_argument_type;
|
||||
|
||||
bool operator()(const T& left, const T& right) const
|
||||
{
|
||||
return left / 2 == right / 2;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Container>
|
||||
void test_unique_impl()
|
||||
@ -152,17 +225,22 @@ namespace boost_range_test_algorithm_unique
|
||||
test_unique_impl<Container>(
|
||||
unique_test_policy(),
|
||||
std::less<int>()
|
||||
);
|
||||
);
|
||||
|
||||
test_unique_impl<Container>(
|
||||
unique_pred_test_policy<std::less<int> >(),
|
||||
unique_pred_test_policy<std::equal_to<int> >(),
|
||||
std::less<int>()
|
||||
);
|
||||
);
|
||||
|
||||
test_unique_impl<Container>(
|
||||
unique_pred_test_policy<std::greater<int> >(),
|
||||
unique_pred_test_policy<std::equal_to<int> >(),
|
||||
std::greater<int>()
|
||||
);
|
||||
);
|
||||
|
||||
test_unique_impl<Container>(
|
||||
unique_pred_test_policy<equal_div_2<int> >(),
|
||||
std::less<int>()
|
||||
);
|
||||
}
|
||||
|
||||
void test_unique()
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
enum Container {};
|
||||
@ -51,6 +52,7 @@ void compat1()
|
||||
{
|
||||
std::vector<int> v;
|
||||
iterator_of< std::vector<int> >::type i = v.begin();
|
||||
boost::ignore_unused_variable_warning(i);
|
||||
}
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
@ -16,6 +16,7 @@ namespace iterator_range_test_detail
|
||||
{
|
||||
double source[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
|
||||
boost::iterator_range<float*> rng = boost::make_iterator_range(source);
|
||||
boost::ignore_unused_variable_warning(rng);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
@ -27,6 +28,13 @@ namespace boost_range_extension_size_test
|
||||
class FooWithoutSize
|
||||
{
|
||||
typedef std::list<int> impl_t;
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<
|
||||
boost::range_size<std::list<int> >::type,
|
||||
std::list<int>::size_type
|
||||
>::value));
|
||||
|
||||
typedef impl_t::const_iterator const_iterator;
|
||||
typedef impl_t::iterator iterator;
|
||||
|
||||
@ -39,12 +47,117 @@ namespace boost_range_extension_size_test
|
||||
private:
|
||||
impl_t m_impl;
|
||||
};
|
||||
|
||||
inline boost::range_size<std::list<int> >::type
|
||||
range_calculate_size(const FooWithoutSize& rng)
|
||||
|
||||
template<typename SizeType>
|
||||
class FooWithSize
|
||||
{
|
||||
return 2u;
|
||||
}
|
||||
public:
|
||||
typedef SizeType size_type;
|
||||
typedef boost::uint8_t* iterator;
|
||||
typedef const boost::uint8_t* const_iterator;
|
||||
|
||||
const_iterator begin() const;
|
||||
iterator begin();
|
||||
const_iterator end() const;
|
||||
iterator end();
|
||||
};
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<
|
||||
boost::uint8_t,
|
||||
boost::range_size<FooWithSize<boost::uint8_t> >::type
|
||||
>::value
|
||||
));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<
|
||||
boost::uint16_t,
|
||||
boost::range_size<FooWithSize<boost::uint16_t> >::type
|
||||
>::value
|
||||
));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<
|
||||
boost::uint32_t,
|
||||
boost::range_size<FooWithSize<boost::uint32_t> >::type
|
||||
>::value
|
||||
));
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<
|
||||
boost::uint64_t,
|
||||
boost::range_size<FooWithSize<boost::uint64_t> >::type
|
||||
>::value
|
||||
));
|
||||
|
||||
class UdtSizeType
|
||||
{
|
||||
public:
|
||||
typedef boost::uint16_t value_type;
|
||||
|
||||
UdtSizeType() : value_(0) { }
|
||||
UdtSizeType(value_type value) : value_(value) { }
|
||||
|
||||
operator value_type() const { return value_; }
|
||||
|
||||
private:
|
||||
value_type value_;
|
||||
};
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<
|
||||
UdtSizeType,
|
||||
boost::range_size<FooWithSize<UdtSizeType> >::type
|
||||
>::value
|
||||
));
|
||||
|
||||
class Foo2WithoutSize
|
||||
{
|
||||
public:
|
||||
struct const_iterator
|
||||
{
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
typedef boost::int8_t difference_type;
|
||||
typedef boost::int16_t value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
|
||||
reference operator*() const;
|
||||
pointer operator->() const;
|
||||
const_iterator& operator++();
|
||||
const_iterator operator++(int);
|
||||
bool operator==(const const_iterator&) const;
|
||||
bool operator!=(const const_iterator&) const;
|
||||
};
|
||||
|
||||
struct iterator : const_iterator
|
||||
{
|
||||
typedef const value_type* pointer;
|
||||
typedef const value_type& reference;
|
||||
|
||||
reference operator*() const;
|
||||
pointer operator->() const;
|
||||
|
||||
iterator& operator++();
|
||||
iterator operator++(int);
|
||||
|
||||
bool operator==(const iterator&) const;
|
||||
bool operator!=(const iterator&) const;
|
||||
};
|
||||
|
||||
const_iterator begin() const;
|
||||
iterator begin();
|
||||
const_iterator end() const;
|
||||
iterator end();
|
||||
};
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<
|
||||
boost::uint8_t,
|
||||
boost::range_size<
|
||||
::boost_range_extension_size_test::Foo2WithoutSize>::type
|
||||
>::value
|
||||
));
|
||||
}
|
||||
|
||||
namespace boost
|
||||
@ -60,6 +173,26 @@ namespace boost
|
||||
};
|
||||
}
|
||||
|
||||
namespace boost_range_extension_size_test
|
||||
{
|
||||
inline boost::range_size<FooWithoutSize>::type
|
||||
range_calculate_size(const FooWithoutSize& rng)
|
||||
{
|
||||
return 2u;
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<
|
||||
boost::make_unsigned<std::ptrdiff_t>::type,
|
||||
boost::range_size<
|
||||
boost_range_extension_size_test::FooWithoutSize>::type
|
||||
>::value
|
||||
));
|
||||
|
||||
typedef boost::make_unsigned<std::ptrdiff_t>::type t1;
|
||||
typedef boost::range_size<boost_range_extension_size_test::FooWithoutSize>::type t1;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
@ -135,7 +135,11 @@ namespace boost
|
||||
{
|
||||
Collection1 c1(rng1);
|
||||
Collection2 c2(rng2);
|
||||
typedef typename boost::range_value<Collection1>::type value_t;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_value<
|
||||
Collection1
|
||||
>::type value_t BOOST_RANGE_UNUSED;
|
||||
|
||||
fill_with_ints(boost::join(c1,c2));
|
||||
|
||||
// Ensure that the size of the written range has not been
|
||||
@ -257,6 +261,18 @@ namespace boost
|
||||
test_join_impl< std::vector<int>, std::deque<int> >();
|
||||
test_join_impl< std::deque<int>, std::vector<int> >();
|
||||
}
|
||||
|
||||
void test_join_iterator_reference_type_constness_ticket8483()
|
||||
{
|
||||
// Just test that this compiles.
|
||||
// Before the fix for bug 8483, the reference type of the joined
|
||||
// range's iterator was incorrect ('int&' instead of 'const int&'),
|
||||
// causing compiler errors.
|
||||
const std::vector<int> v1;
|
||||
std::vector<int> v2;
|
||||
std::vector<int> joined;
|
||||
boost::push_back(joined, join(v1, v2));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -268,6 +284,7 @@ init_unit_test_suite(int argc, char* argv[])
|
||||
= BOOST_TEST_SUITE( "RangeTestSuite.adaptor.joined" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &boost::join_test ) );
|
||||
test->add( BOOST_TEST_CASE( &boost::test_join_iterator_reference_type_constness_ticket8483 ) );
|
||||
|
||||
return test;
|
||||
}
|
||||
|
74
test/test_driver/range_overload_test_driver.hpp
Normal file
74
test/test_driver/range_overload_test_driver.hpp
Normal file
@ -0,0 +1,74 @@
|
||||
// Copyright Neil Groves 2013. Use, modification and
|
||||
// distribution is subject to 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)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
// Acknowledgments:
|
||||
// Implemented by Andy in response to Ticket 6888 - unique fix
|
||||
//
|
||||
#ifndef BOOST_RANGE_TEST_TEST_DRIVER_RANGE_OVERLOAD_TEST_DRIVER_HPP_INCLUDED
|
||||
#define BOOST_RANGE_TEST_TEST_DRIVER_RANGE_OVERLOAD_TEST_DRIVER_HPP_INCLUDED
|
||||
|
||||
#include "range_return_test_driver.hpp"
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_test
|
||||
{
|
||||
|
||||
// A test driver to exercise a test through range_return_test_driver
|
||||
// plus the overload that determines the return_type by overload
|
||||
//
|
||||
// The test driver also contains the code required to check the
|
||||
// return value correctness.
|
||||
//
|
||||
// The TestPolicy needs to implement all those required by
|
||||
// range_return_test_driver, and additionally
|
||||
//
|
||||
// - perform the boost range version of the algorithm that determines
|
||||
// the return_type by overload
|
||||
class range_overload_test_driver : range_return_test_driver
|
||||
{
|
||||
public:
|
||||
template< class Container,
|
||||
class TestPolicy >
|
||||
void operator()(Container& cont, TestPolicy policy)
|
||||
{
|
||||
range_return_test_driver::operator()(cont, policy);
|
||||
test_range_overload<Container, TestPolicy>()(cont, policy);
|
||||
}
|
||||
|
||||
private:
|
||||
template< class Container, class TestPolicy >
|
||||
struct test_range_overload
|
||||
{
|
||||
void operator()(Container& cont, TestPolicy policy)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iterator_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME TestPolicy::template test_range_overload<Container> test_range_overload_t;
|
||||
const range_return_value result_type = test_range_overload_t::result_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_return<Container, result_type>::type range_return_t;
|
||||
|
||||
Container reference(cont);
|
||||
Container test_cont(cont);
|
||||
|
||||
test_range_overload_t test_range_overload_fn;
|
||||
range_return_t range_result = test_range_overload_fn(policy, test_cont);
|
||||
|
||||
iterator_t reference_it = policy.reference(reference);
|
||||
|
||||
check_results<result_type>::test(test_cont, reference,
|
||||
range_result, reference_it);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // include guard
|
Reference in New Issue
Block a user