forked from boostorg/range
Compare commits
29 Commits
boost-1.64
...
fix-boost-
Author | SHA1 | Date | |
---|---|---|---|
9e5680b590 | |||
e48b9c38e7 | |||
5a37aa4e98 | |||
5196baa1b0 | |||
1947daf1b5 | |||
7ca999c662 | |||
e7ebe14707 | |||
3225aaf82b | |||
262c0f96b3 | |||
1a3aeeb336 | |||
78a8f5bf3d | |||
9bf860fd30 | |||
64c83341ab | |||
6241dc62aa | |||
f83381d938 | |||
926318105e | |||
140866b402 | |||
490ba3fdcd | |||
e4f456d438 | |||
adcb071dc6 | |||
7fad9837fb | |||
11dbb1cb5a | |||
e961e66909 | |||
8847fd63cb | |||
62941f740d | |||
0c930a3697 | |||
09084d6355 | |||
9ca1622dd0 | |||
474c62ab16 |
@ -28,3 +28,8 @@ boostbook quickbook
|
||||
<format>pdf:<xsl:param>img.src.path=$(images_location)/
|
||||
;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease : quickbook ;
|
||||
explicit boostrelease ;
|
||||
|
@ -46,7 +46,7 @@
|
||||
[[`<boost/range/adaptor/copied.hpp>`] [__range_adaptors_copied__]]
|
||||
[[`<boost/range/adaptor/filtered.hpp>`] [__range_adaptors_filtered__]]
|
||||
[[`<boost/range/adaptor/indexed.hpp>`] [__range_adaptors_indexed__]]
|
||||
[[`<boost/range/adaptor/indirected.hpp.`] [__range_adaptors_indirected__]]
|
||||
[[`<boost/range/adaptor/indirected.hpp>`] [__range_adaptors_indirected__]]
|
||||
[[`<boost/range/adaptor/map.hpp>`] [__range_adaptors_map_keys__ __range_adaptors_map_values__]]
|
||||
[[`<boost/range/adaptor/replaced.hpp>`] [__range_adaptors_replaced__]]
|
||||
[[`<boost/range/adaptor/replaced_if.hpp>`] [__range_adaptors_replaced_if__]]
|
||||
|
@ -172,6 +172,7 @@ rng | boost::adaptors::adaptor_generator
|
||||
[include adaptors/indirected.qbk]
|
||||
[include adaptors/map_keys.qbk]
|
||||
[include adaptors/map_values.qbk]
|
||||
[include adaptors/ref_unwrapped.qbk]
|
||||
[include adaptors/replaced.qbk]
|
||||
[include adaptors/replaced_if.qbk]
|
||||
[include adaptors/reversed.qbk]
|
||||
|
32
doc/reference/adaptors/ref_unwrapped.qbk
Normal file
32
doc/reference/adaptors/ref_unwrapped.qbk
Normal file
@ -0,0 +1,32 @@
|
||||
[/
|
||||
Copyright 2015 Robin Eckert
|
||||
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)
|
||||
/]
|
||||
[section:ref_unwrapped ref_unwrapped]
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::ref_unwrapped`]]
|
||||
[[Function] [`boost::adaptors::ref_unwrap(rng)`]]
|
||||
]
|
||||
|
||||
This adaptor produces a range than applies `.get()` on all values in
|
||||
the range. It is useful for iterating ranges of
|
||||
`std::reference_wrapper` values or values using similar semantics.
|
||||
|
||||
The adaptor is C++11 (and above) only.
|
||||
|
||||
* [*Precondition:] The `value_type` of the range has a `.get() const`.
|
||||
* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.get()` where `y` is the corresponding element in the original range.
|
||||
* [*Range Category:] __single_pass_range__
|
||||
* [*Range Return Type:] `boost::unwrap_ref_range<decltype(rng)>`
|
||||
* [*Returned Range Category:] The range category of `rng`.
|
||||
|
||||
[section:ref_unwrapped_example ref_unwrapped example]
|
||||
[import ../../../test/adaptor_test/ref_unwrapped_example.cpp]
|
||||
[ref_unwrapped_example]
|
||||
[endsect]
|
||||
|
||||
This would produce the output `123`.
|
||||
[endsect]
|
@ -7,8 +7,8 @@
|
||||
|
||||
[table
|
||||
[[Syntax] [Code]]
|
||||
[[Pipe] [`rng | boost::adaptors::replaced(new_value, old_value)`]]
|
||||
[[Function] [`boost::adaptors::replace(rng, new_value, old_value)`]]
|
||||
[[Pipe] [`rng | boost::adaptors::replaced(old_value, new_value)`]]
|
||||
[[Function] [`boost::adaptors::replace(rng, old_value, new_value)`]]
|
||||
]
|
||||
|
||||
* [*Precondition:]
|
||||
|
102
include/boost/range/adaptor/ref_unwrapped.hpp
Normal file
102
include/boost/range/adaptor/ref_unwrapped.hpp
Normal file
@ -0,0 +1,102 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Robin Eckert 2015.
|
||||
// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_ADAPTOR_REF_UNWRAPPED_HPP
|
||||
#define BOOST_RANGE_ADAPTOR_REF_UNWRAPPED_HPP
|
||||
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <boost/range/reference.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
struct ref_unwrapped_forwarder {};
|
||||
|
||||
template<class SinglePassRange>
|
||||
struct unwrap_ref
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
range_reference<SinglePassRange>::type argument_type;
|
||||
|
||||
using result_type = decltype(std::declval<argument_type>().get() );
|
||||
|
||||
result_type operator()( argument_type &&r ) const
|
||||
{
|
||||
return r.get();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class SinglePassRange>
|
||||
class unwrap_ref_range
|
||||
: public transformed_range<unwrap_ref<SinglePassRange>,
|
||||
SinglePassRange>
|
||||
{
|
||||
using base = transformed_range<unwrap_ref<SinglePassRange>,
|
||||
SinglePassRange>;
|
||||
public:
|
||||
using transform_fn_type = unwrap_ref<SinglePassRange>;
|
||||
using source_range_type = SinglePassRange;
|
||||
|
||||
unwrap_ref_range(transform_fn_type fn, source_range_type &rng)
|
||||
: base(fn, rng)
|
||||
{
|
||||
}
|
||||
|
||||
unwrap_ref_range(const base &other) : base(other) {}
|
||||
};
|
||||
|
||||
template<class SinglePassRange>
|
||||
inline unwrap_ref_range<SinglePassRange>
|
||||
operator|(SinglePassRange& r, ref_unwrapped_forwarder)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<SinglePassRange>));
|
||||
|
||||
return operator|( r,
|
||||
boost::adaptors::transformed(unwrap_ref<SinglePassRange>()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using range_detail::unwrap_ref_range;
|
||||
|
||||
namespace adaptors
|
||||
{
|
||||
namespace
|
||||
{
|
||||
const range_detail::ref_unwrapped_forwarder ref_unwrapped =
|
||||
range_detail::ref_unwrapped_forwarder();
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
inline unwrap_ref_range<SinglePassRange>
|
||||
ref_unwrap(SinglePassRange& rng)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<SinglePassRange>));
|
||||
|
||||
return unwrap_ref_range<SinglePassRange>(
|
||||
range_detail::unwrap_ref<SinglePassRange>(), rng );
|
||||
}
|
||||
} // 'adaptors'
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -9,12 +9,12 @@
|
||||
#ifndef BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED
|
||||
#define BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED
|
||||
|
||||
#include <boost/algorithm/minmax_element.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/range/detail/range_return.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -32,7 +32,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
|
||||
max_element(ForwardRange& rng)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
|
||||
return std::max_element(boost::begin(rng), boost::end(rng));
|
||||
return boost::first_max_element(boost::begin(rng), boost::end(rng));
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -41,7 +41,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
|
||||
max_element(const ForwardRange& rng)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
|
||||
return std::max_element(boost::begin(rng), boost::end(rng));
|
||||
return boost::first_max_element(boost::begin(rng), boost::end(rng));
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -50,7 +50,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
|
||||
max_element(ForwardRange& rng, BinaryPredicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
|
||||
return std::max_element(boost::begin(rng), boost::end(rng), pred);
|
||||
return boost::first_max_element(boost::begin(rng), boost::end(rng), pred);
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -59,7 +59,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
|
||||
max_element(const ForwardRange& rng, BinaryPredicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
|
||||
return std::max_element(boost::begin(rng), boost::end(rng), pred);
|
||||
return boost::first_max_element(boost::begin(rng), boost::end(rng), pred);
|
||||
}
|
||||
|
||||
// range_return overloads
|
||||
@ -71,7 +71,7 @@ max_element(ForwardRange& rng)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
|
||||
return range_return<ForwardRange,re>::pack(
|
||||
std::max_element(boost::begin(rng), boost::end(rng)),
|
||||
boost::first_max_element(boost::begin(rng), boost::end(rng)),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ max_element(const ForwardRange& rng)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
|
||||
return range_return<const ForwardRange,re>::pack(
|
||||
std::max_element(boost::begin(rng), boost::end(rng)),
|
||||
boost::first_max_element(boost::begin(rng), boost::end(rng)),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ max_element(ForwardRange& rng, BinaryPredicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
|
||||
return range_return<ForwardRange,re>::pack(
|
||||
std::max_element(boost::begin(rng), boost::end(rng), pred),
|
||||
boost::first_max_element(boost::begin(rng), boost::end(rng), pred),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ max_element(const ForwardRange& rng, BinaryPredicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
|
||||
return range_return<const ForwardRange,re>::pack(
|
||||
std::max_element(boost::begin(rng), boost::end(rng), pred),
|
||||
boost::first_max_element(boost::begin(rng), boost::end(rng), pred),
|
||||
rng);
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@
|
||||
#ifndef BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED
|
||||
#define BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED
|
||||
|
||||
#include <boost/algorithm/minmax_element.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/range/detail/range_return.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -32,7 +32,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
|
||||
min_element(ForwardRange& rng)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
|
||||
return std::min_element(boost::begin(rng), boost::end(rng));
|
||||
return boost::first_min_element(boost::begin(rng), boost::end(rng));
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -41,7 +41,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
|
||||
min_element(const ForwardRange& rng)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
|
||||
return std::min_element(boost::begin(rng), boost::end(rng));
|
||||
return boost::first_min_element(boost::begin(rng), boost::end(rng));
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -50,7 +50,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
|
||||
min_element(ForwardRange& rng, BinaryPredicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
|
||||
return std::min_element(boost::begin(rng), boost::end(rng), pred);
|
||||
return boost::first_min_element(boost::begin(rng), boost::end(rng), pred);
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -59,7 +59,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
|
||||
min_element(const ForwardRange& rng, BinaryPredicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
|
||||
return std::min_element(boost::begin(rng), boost::end(rng), pred);
|
||||
return boost::first_min_element(boost::begin(rng), boost::end(rng), pred);
|
||||
}
|
||||
|
||||
// range_return overloads
|
||||
@ -71,7 +71,7 @@ min_element(ForwardRange& rng)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
|
||||
return range_return<ForwardRange,re>::pack(
|
||||
std::min_element(boost::begin(rng), boost::end(rng)),
|
||||
boost::first_min_element(boost::begin(rng), boost::end(rng)),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ min_element(const ForwardRange& rng)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
|
||||
return range_return<const ForwardRange,re>::pack(
|
||||
std::min_element(boost::begin(rng), boost::end(rng)),
|
||||
boost::first_min_element(boost::begin(rng), boost::end(rng)),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ min_element(ForwardRange& rng, BinaryPredicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
|
||||
return range_return<ForwardRange,re>::pack(
|
||||
std::min_element(boost::begin(rng), boost::end(rng), pred),
|
||||
boost::first_min_element(boost::begin(rng), boost::end(rng), pred),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ min_element(const ForwardRange& rng, BinaryPredicate pred)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
|
||||
return range_return<const ForwardRange,re>::pack(
|
||||
std::min_element(boost::begin(rng), boost::end(rng), pred),
|
||||
boost::first_min_element(boost::begin(rng), boost::end(rng), pred),
|
||||
rng);
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ inline Container& insert( Container& on, const Range& from )
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
|
||||
on.insert(boost::begin(from), boost::end(from));
|
||||
return on;
|
||||
}
|
||||
|
||||
} // namespace range
|
||||
|
@ -25,6 +25,11 @@
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T) || !defined(BOOST_NO_CXX11_CHAR32_T)
|
||||
#include <string> // for std::char_traits
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#include <cwchar>
|
||||
#endif
|
||||
@ -38,6 +43,20 @@ namespace boost
|
||||
return strlen( s );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_CHAR16_T
|
||||
inline std::size_t length( const char16_t* s )
|
||||
{
|
||||
return std::char_traits<char16_t>::length( s );
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_CHAR32_T
|
||||
inline std::size_t length( const char32_t* s )
|
||||
{
|
||||
return std::char_traits<char32_t>::length( s );
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
inline std::size_t length( const wchar_t* s )
|
||||
{
|
||||
@ -61,6 +80,30 @@ namespace boost
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_CHAR16_T
|
||||
inline bool is_char_ptr( char16_t* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool is_char_ptr( const char16_t* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_CHAR32_T
|
||||
inline bool is_char_ptr( char32_t* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool is_char_ptr( const char32_t* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
inline bool is_char_ptr( wchar_t* )
|
||||
{
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <boost/range/detail/misc_concept.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
#include <iterator>
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \brief Concept checks for the Boost Range library.
|
||||
@ -164,10 +166,10 @@ namespace boost {
|
||||
// work
|
||||
(void)(i++);
|
||||
|
||||
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r1(*i);
|
||||
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference r1(*i);
|
||||
boost::ignore_unused_variable_warning(r1);
|
||||
|
||||
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r2(*(++i));
|
||||
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference r2(*(++i));
|
||||
boost::ignore_unused_variable_warning(r2);
|
||||
}
|
||||
private:
|
||||
@ -181,7 +183,7 @@ namespace boost {
|
||||
, DefaultConstructible<Iterator>
|
||||
{
|
||||
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::difference_type difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::difference_type difference_type;
|
||||
|
||||
BOOST_MPL_ASSERT((is_integral<difference_type>));
|
||||
BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true);
|
||||
@ -200,7 +202,7 @@ namespace boost {
|
||||
// is convertible to reference.
|
||||
Iterator i2(i++);
|
||||
boost::ignore_unused_variable_warning(i2);
|
||||
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r(*(i++));
|
||||
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference r(*(i++));
|
||||
boost::ignore_unused_variable_warning(r);
|
||||
}
|
||||
private:
|
||||
|
@ -18,10 +18,8 @@
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/detail/sfinae.hpp>
|
||||
#include <boost/type_traits/is_void.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -71,7 +69,7 @@ namespace boost
|
||||
BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_string_ = (boost::mpl::or_<boost::mpl::bool_<is_const_char_ptr_>, boost::mpl::bool_<is_const_wchar_t_ptr_> >::value ));
|
||||
BOOST_STATIC_CONSTANT( bool, is_string_ = (is_const_char_ptr_ || is_const_wchar_t_ptr_));
|
||||
BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array<C>::value );
|
||||
|
||||
};
|
||||
|
@ -153,8 +153,12 @@ template<typename Iterator1
|
||||
typename iterator_reference<Iterator2>::type
|
||||
>::type
|
||||
>::value,
|
||||
typename add_const<
|
||||
typename iterator_reference<Iterator1>::type
|
||||
typename add_reference<
|
||||
typename add_const<
|
||||
typename remove_reference<
|
||||
typename iterator_reference<Iterator1>::type
|
||||
>::type
|
||||
>::type
|
||||
>::type,
|
||||
typename iterator_reference<Iterator1>::type
|
||||
>::type
|
||||
|
@ -37,9 +37,9 @@ namespace boost
|
||||
T,
|
||||
BOOST_DEDUCED_TYPENAME ::boost::enable_if<
|
||||
BOOST_DEDUCED_TYPENAME mpl::eval_if<is_const<T>,
|
||||
has_type<range_const_iterator<
|
||||
has_type<boost::range_const_iterator<
|
||||
BOOST_DEDUCED_TYPENAME remove_const<T>::type> >,
|
||||
has_type<range_mutable_iterator<T> >
|
||||
has_type<boost::range_mutable_iterator<T> >
|
||||
>::type
|
||||
>::type
|
||||
>
|
||||
@ -57,7 +57,7 @@ namespace boost
|
||||
struct has_range_const_iterator_impl<
|
||||
T,
|
||||
BOOST_DEDUCED_TYPENAME ::boost::enable_if<
|
||||
has_type<range_const_iterator<T> >
|
||||
has_type<boost::range_const_iterator<T> >
|
||||
>::type
|
||||
>
|
||||
: boost::mpl::true_
|
||||
|
@ -83,11 +83,6 @@ namespace boost
|
||||
detail::range_size<T>
|
||||
{ };
|
||||
|
||||
template< class T >
|
||||
struct range_size<const T > :
|
||||
detail::range_size<T>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
@ -59,6 +59,8 @@ test-suite range :
|
||||
[ range-test adaptor_test/indexed ]
|
||||
[ range-test adaptor_test/indirected ]
|
||||
[ range-test adaptor_test/map ]
|
||||
[ range-test adaptor_test/ref_unwrapped ]
|
||||
[ range-test adaptor_test/ref_unwrapped_example ]
|
||||
[ range-test adaptor_test/replaced ]
|
||||
[ range-test adaptor_test/replaced_if ]
|
||||
[ range-test adaptor_test/reversed ]
|
||||
|
101
test/adaptor_test/ref_unwrapped.cpp
Normal file
101
test/adaptor_test/ref_unwrapped.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Robin Eckert 2015. 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/
|
||||
//
|
||||
#include <boost/range/adaptor/ref_unwrapped.hpp>
|
||||
|
||||
#define BOOST_TEST_MAIN
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && !defined(BOOST_NO_CXX11_RANGE_BASED_FOR)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_mutable)
|
||||
{
|
||||
int one = 1;
|
||||
int two = 2;
|
||||
int three = 3;
|
||||
|
||||
std::vector<std::reference_wrapper<int>> input_values{one, two, three};
|
||||
|
||||
const std::vector<int*> expected{&one, &two, &three};
|
||||
std::vector<int*> actual;
|
||||
|
||||
for (auto&& value : input_values | adaptors::ref_unwrapped)
|
||||
{
|
||||
actual.push_back(&value);
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(),
|
||||
expected.end(),
|
||||
actual.begin(),
|
||||
actual.end());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_const_range)
|
||||
{
|
||||
int one = 1;
|
||||
int two = 2;
|
||||
int three = 3;
|
||||
|
||||
const std::vector<std::reference_wrapper<int>> input_values{one, two, three};
|
||||
|
||||
const std::vector<int*> expected{&one, &two, &three};
|
||||
std::vector<int*> actual;
|
||||
|
||||
for (auto&& value : input_values | adaptors::ref_unwrapped)
|
||||
{
|
||||
actual.push_back(&value);
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(),
|
||||
expected.end(),
|
||||
actual.begin(),
|
||||
actual.end());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_const_reference)
|
||||
{
|
||||
const int one = 1;
|
||||
const int two = 2;
|
||||
const int three = 3;
|
||||
|
||||
const std::vector<std::reference_wrapper<const int>> input_values{one, two, three};
|
||||
|
||||
const std::vector<const int*> expected{&one, &two, &three};
|
||||
std::vector<const int*> actual;
|
||||
|
||||
for (auto&& value : input_values | adaptors::ref_unwrapped)
|
||||
{
|
||||
actual.push_back(&value);
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(),
|
||||
expected.end(),
|
||||
actual.begin(),
|
||||
actual.end());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BOOST_AUTO_TEST_CASE(empty)
|
||||
{
|
||||
// C++11 only
|
||||
}
|
||||
|
||||
#endif
|
47
test/adaptor_test/ref_unwrapped_example.cpp
Normal file
47
test/adaptor_test/ref_unwrapped_example.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Robin Eckert 2015. 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/
|
||||
//
|
||||
//[ref_unwrapped_example
|
||||
#include <boost/range/adaptor/ref_unwrapped.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
struct example
|
||||
{
|
||||
int value;
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
//<-
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) \
|
||||
&& !defined(BOOST_NO_CXX11_RANGE_BASED_FOR) \
|
||||
&& !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
|
||||
&& !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
|
||||
//->
|
||||
using boost::adaptors::ref_unwrapped;
|
||||
|
||||
example one{1};
|
||||
example two{2};
|
||||
example three{3};
|
||||
|
||||
std::vector<std::reference_wrapper<example> > input{one, two, three};
|
||||
|
||||
for (auto&& entry : input | ref_unwrapped)
|
||||
{
|
||||
std::cout << entry.value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
//<-
|
||||
#endif
|
||||
//->
|
||||
}
|
||||
//]
|
@ -9,7 +9,7 @@
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
// The strided_defect_Trac5014 test case is a modified version of a test case
|
||||
// contributed by Michel Morin as part of the trac ticket.
|
||||
// contributed by Maxim Yanchenko as part of the trac ticket.
|
||||
//
|
||||
// The deque test case has been removed due to erroneous standard library
|
||||
// implementations causing test failures.
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
void check_iterator_pair()
|
||||
{
|
||||
@ -39,23 +41,23 @@ void check_iterator_pair()
|
||||
|
||||
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value<pair_t>::type,
|
||||
boost::detail::iterator_traits<pair_t::first_type>::value_type>::value ));
|
||||
std::iterator_traits<pair_t::first_type>::value_type>::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<pair_t>::type, pair_t::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_const_iterator<pair_t>::type, pair_t::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference<pair_t>::type,
|
||||
boost::detail::iterator_traits<pair_t::first_type>::difference_type >::value ));
|
||||
std::iterator_traits<pair_t::first_type>::difference_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<pair_t>::type, std::size_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<pair_t>::type, pair_t::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_t>::type, const_pair_t::first_type >::value ));
|
||||
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value<const_pair_tt>::type,
|
||||
boost::detail::iterator_traits<const_pair_t::first_type>::value_type>::value ));
|
||||
std::iterator_traits<const_pair_t::first_type>::value_type>::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
//
|
||||
// This behavior is not supported with v2.
|
||||
//BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference<const_pair_tt>::type,
|
||||
boost::detail::iterator_traits<const_pair_tt::first_type>::difference_type >::value ));
|
||||
std::iterator_traits<const_pair_tt::first_type>::difference_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<const_pair_tt>::type, std::size_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
|
@ -277,6 +277,7 @@ namespace boost
|
||||
std::vector<int> v2;
|
||||
std::vector<int> joined;
|
||||
boost::push_back(joined, join(v1, v2));
|
||||
boost::push_back(joined, join(v2, v1));
|
||||
}
|
||||
|
||||
namespace trac7376
|
||||
|
Reference in New Issue
Block a user