mirror of
https://github.com/boostorg/iterator.git
synced 2025-05-10 07:33:53 +00:00
Revert [68076], refs #1427.
Will try to fix this properly in 1.47. [SVN r68524]
This commit is contained in:
parent
5a88e6f958
commit
d45b57c33c
@ -20,8 +20,6 @@
|
|||||||
#include <boost/type_traits/is_reference.hpp>
|
#include <boost/type_traits/is_reference.hpp>
|
||||||
#include <boost/type_traits/remove_const.hpp>
|
#include <boost/type_traits/remove_const.hpp>
|
||||||
#include <boost/type_traits/remove_reference.hpp>
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
#include <boost/utility/result_of.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
|
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
|
||||||
# include <boost/type_traits/is_base_and_derived.hpp>
|
# include <boost/type_traits/is_base_and_derived.hpp>
|
||||||
@ -37,18 +35,33 @@ namespace boost
|
|||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template <class UnaryFunc>
|
||||||
|
struct function_object_result
|
||||||
|
{
|
||||||
|
typedef typename UnaryFunc::result_type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||||
|
template <class Return, class Argument>
|
||||||
|
struct function_object_result<Return(*)(Argument)>
|
||||||
|
{
|
||||||
|
typedef Return type;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Compute the iterator_adaptor instantiation to be used for transform_iterator
|
// Compute the iterator_adaptor instantiation to be used for transform_iterator
|
||||||
template <class UnaryFunc, class Iterator, class Reference, class Value>
|
template <class UnaryFunc, class Iterator, class Reference, class Value>
|
||||||
struct transform_iterator_base
|
struct transform_iterator_base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef typename std::iterator_traits<Iterator>::reference Arg1;
|
|
||||||
|
|
||||||
// By default, dereferencing the iterator yields the same as
|
// By default, dereferencing the iterator yields the same as
|
||||||
// the function.
|
// the function. Do we need to adjust the way
|
||||||
|
// function_object_result is computed for the standard
|
||||||
|
// proposal (e.g. using Doug's result_of)?
|
||||||
typedef typename ia_dflt_help<
|
typedef typename ia_dflt_help<
|
||||||
Reference
|
Reference
|
||||||
, result_of<UnaryFunc(typename std::iterator_traits<Iterator>::value_type)>
|
, function_object_result<UnaryFunc>
|
||||||
>::type reference;
|
>::type reference;
|
||||||
|
|
||||||
// To get the default for Value: remove any reference on the
|
// To get the default for Value: remove any reference on the
|
||||||
@ -100,7 +113,7 @@ namespace boost
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<
|
||||||
class OtherUnaryFunction
|
class OtherUnaryFunction
|
||||||
, class OtherIterator
|
, class OtherIterator
|
||||||
, class OtherReference
|
, class OtherReference
|
||||||
|
@ -102,16 +102,6 @@ int mult_2(int arg)
|
|||||||
return arg*2;
|
return arg*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct polymorphic_mult_functor
|
|
||||||
{
|
|
||||||
//Implement result_of protocol
|
|
||||||
template <class FArgs> struct result;
|
|
||||||
template <class F, class T> struct result<F(T)> {typedef T type;};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
typename result<polymorphic_mult_functor(T)>::type
|
|
||||||
operator()(const T& _arg) const {return _arg*2;}
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
@ -254,25 +244,5 @@ main()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test transform_iterator with polymorphic object function
|
|
||||||
{
|
|
||||||
int x[N], y[N];
|
|
||||||
for (int k = 0; k < N; ++k)
|
|
||||||
x[k] = k;
|
|
||||||
std::copy(x, x + N, y);
|
|
||||||
|
|
||||||
for (int k2 = 0; k2 < N; ++k2)
|
|
||||||
x[k2] = x[k2] * 2;
|
|
||||||
|
|
||||||
boost::input_iterator_test(
|
|
||||||
boost::make_transform_iterator(y, polymorphic_mult_functor()), x[0], x[1]);
|
|
||||||
|
|
||||||
boost::input_iterator_test(
|
|
||||||
boost::make_transform_iterator(&y[0], polymorphic_mult_functor()), x[0], x[1]);
|
|
||||||
|
|
||||||
boost::random_access_readable_iterator_test(
|
|
||||||
boost::make_transform_iterator(y, polymorphic_mult_functor()), N, x);
|
|
||||||
}
|
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user