File indexing completed on 2025-01-30 09:59:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_RANGE_ADAPTOR_REF_UNWRAPPED_HPP
0013 #define BOOST_RANGE_ADAPTOR_REF_UNWRAPPED_HPP
0014
0015 #include <boost/range/adaptor/transformed.hpp>
0016 #include <boost/range/reference.hpp>
0017 #include <boost/range/concepts.hpp>
0018 #include <boost/type_traits/declval.hpp>
0019 #include <utility>
0020
0021 #if !defined(BOOST_NO_CXX11_DECLTYPE)
0022
0023 namespace boost
0024 {
0025 namespace range_detail
0026 {
0027 struct ref_unwrapped_forwarder {};
0028
0029 template<class SinglePassRange>
0030 struct unwrap_ref
0031 {
0032 typedef BOOST_DEDUCED_TYPENAME
0033 range_reference<SinglePassRange>::type argument_type;
0034
0035 typedef decltype( boost::declval<argument_type>().get() ) result_type;
0036
0037 result_type operator()( argument_type &&r ) const
0038 {
0039 return r.get();
0040 }
0041 };
0042
0043
0044 template<class SinglePassRange>
0045 class unwrap_ref_range
0046 : public transformed_range<unwrap_ref<SinglePassRange>,
0047 SinglePassRange>
0048 {
0049 typedef transformed_range<unwrap_ref<SinglePassRange>,
0050 SinglePassRange> base;
0051 public:
0052 typedef unwrap_ref<SinglePassRange> transform_fn_type;
0053 typedef SinglePassRange source_range_type;
0054
0055 unwrap_ref_range(transform_fn_type fn, source_range_type &rng)
0056 : base(fn, rng)
0057 {
0058 }
0059
0060 unwrap_ref_range(const base &other) : base(other) {}
0061 };
0062
0063 template<class SinglePassRange>
0064 inline unwrap_ref_range<SinglePassRange>
0065 operator|(SinglePassRange& r, ref_unwrapped_forwarder)
0066 {
0067 BOOST_RANGE_CONCEPT_ASSERT((
0068 SinglePassRangeConcept<SinglePassRange>));
0069
0070 return operator|( r,
0071 boost::adaptors::transformed(unwrap_ref<SinglePassRange>()));
0072 }
0073
0074 }
0075
0076 using range_detail::unwrap_ref_range;
0077
0078 namespace adaptors
0079 {
0080 namespace
0081 {
0082 const range_detail::ref_unwrapped_forwarder ref_unwrapped =
0083 range_detail::ref_unwrapped_forwarder();
0084 }
0085
0086 template<class SinglePassRange>
0087 inline unwrap_ref_range<SinglePassRange>
0088 ref_unwrap(SinglePassRange& rng)
0089 {
0090 BOOST_RANGE_CONCEPT_ASSERT((
0091 SinglePassRangeConcept<SinglePassRange>));
0092
0093 return unwrap_ref_range<SinglePassRange>(
0094 range_detail::unwrap_ref<SinglePassRange>(), rng );
0095 }
0096 }
0097
0098 }
0099
0100 #endif
0101
0102 #endif