8#ifndef INCLUDED_BDLB_TRANSFORMITERATOR
9#define INCLUDED_BDLB_TRANSFORMITERATOR
230#include <bdlscm_version.h>
247#include <bsl_algorithm.h>
248#include <bsl_functional.h>
249#include <bsl_iterator.h>
250#include <bsl_utility.h>
252#ifndef BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE
260template <
class FUNCTOR,
class ITERATOR>
261class TransformIterator;
269template <
class FUNCTOR,
class ITERATOR>
274#ifndef BSLS_COMPILERFEATURES_SUPPORT_DECLTYPE
289 typedef decltype(bsl::declval<FUNCTOR>()(*bsl::declval<ITERATOR>()))
303 typename BaseIteratorTraits::iterator_category,
307 typename bsl::remove_reference<ResultType>::type>::type
value_type;
309 typedef typename bsl::remove_reference<ResultType>::type *
pointer;
314#if defined(BSLS_LIBRARYFEATURES_STDCPP_LIBCSTD)
334template <
class RESULT,
class ARGUMENT,
class ITERATOR>
339template <
class RESULT,
class ARGUMENT,
class ITERATOR>
359template <
class BASE_TYPE,
bool>
363template <
class BASE_TYPE>
383template <
class BASE_TYPE,
bool>
387template <
class BASE_TYPE>
405template <
class FUNCTOR,
class ITERATOR>
408 TransformIterator<FUNCTOR, ITERATOR>,
409 bslma::UsesBslmaAllocator<ITERATOR>::value>
411 TransformIterator<FUNCTOR, ITERATOR>,
412 !bslma::UsesBslmaAllocator<ITERATOR>::value &&
413 bslma::UsesBslmaAllocator<FUNCTOR>::value>
414#if defined(BSLS_LIBRARYFEATURES_STDCPP_LIBCSTD)
579 const FUNCTOR&
functor()
const;
604 template <
class FUNCTOR,
class ITERATOR>
606 const ITERATOR& iterator,
607 const FUNCTOR& functor,
618template <
class FUNCTOR,
class ITERATOR>
627template <
class FUNCTOR,
class ITERATOR>
636template <
class FUNCTOR,
class ITERATOR>
645template <
class FUNCTOR,
class ITERATOR>
654template <
class FUNCTOR,
class ITERATOR>
663template <
class FUNCTOR,
class ITERATOR>
670template <
class FUNCTOR,
class ITERATOR>
678template <
class FUNCTOR,
class ITERATOR>
687template <
class FUNCTOR,
class ITERATOR>
696template <
class FUNCTOR,
class ITERATOR>
705template <
class FUNCTOR,
class ITERATOR>
713template <
class FUNCTOR,
class ITERATOR>
723template <
class FUNCTOR,
class ITERATOR>
736template <
class BASE_TYPE>
741 return static_cast<const BASE_TYPE&
>(*this).iterator().allocator();
749template <
class BASE_TYPE>
754 return static_cast<const BASE_TYPE&
>(*this).functor().allocator();
762template <
class FUNCTOR,
class ITERATOR>
770template <
class FUNCTOR,
class ITERATOR>
774: d_iterator(basicAllocator)
775, d_functor(basicAllocator)
779template <
class FUNCTOR,
class ITERATOR>
782 const ITERATOR& iterator,
785: d_iterator(iterator, basicAllocator)
786, d_functor(functor, basicAllocator)
790template <
class FUNCTOR,
class ITERATOR>
795: d_iterator(original.iterator(), basicAllocator)
796, d_functor(original.functor(), basicAllocator)
801template <
class FUNCTOR,
class ITERATOR>
812template <
class FUNCTOR,
class ITERATOR>
817 iterator() += offset;
821template <
class FUNCTOR,
class ITERATOR>
826 iterator() -= offset;
830template <
class FUNCTOR,
class ITERATOR>
839template <
class FUNCTOR,
class ITERATOR>
848template <
class FUNCTOR,
class ITERATOR>
853 return functor()(*iterator());
856template <
class FUNCTOR,
class ITERATOR>
864template <
class FUNCTOR,
class ITERATOR>
869 return functor()(iterator()[offset]);
872template <
class FUNCTOR,
class ITERATOR>
876 return d_functor.object();
879template <
class FUNCTOR,
class ITERATOR>
883 return d_iterator.object();
888template <
class FUNCTOR,
class ITERATOR>
894 swap(functor(), other.
functor());
899template <
class FUNCTOR,
class ITERATOR>
904 return functor()(*iterator());
907template <
class FUNCTOR,
class ITERATOR>
915template <
class FUNCTOR,
class ITERATOR>
920 return functor()(iterator()[offset]);
923template <
class FUNCTOR,
class ITERATOR>
927 return d_functor.object();
930template <
class FUNCTOR,
class ITERATOR>
934 return d_iterator.object();
940template <
class FUNCTOR,
class ITERATOR>
943 const TransformIterator<FUNCTOR, ITERATOR>& rhs)
945 return lhs.iterator() == rhs.iterator();
948template <
class FUNCTOR,
class ITERATOR>
951 const TransformIterator<FUNCTOR, ITERATOR>& rhs)
953 return lhs.iterator() != rhs.iterator();
956template <
class FUNCTOR,
class ITERATOR>
959 const TransformIterator<FUNCTOR, ITERATOR>& rhs)
961 return lhs.iterator() < rhs.iterator();
964template <
class FUNCTOR,
class ITERATOR>
967 const TransformIterator<FUNCTOR, ITERATOR>& rhs)
969 return lhs.iterator() > rhs.iterator();
972template <
class FUNCTOR,
class ITERATOR>
975 const TransformIterator<FUNCTOR, ITERATOR>& rhs)
977 return lhs.iterator() <= rhs.iterator();
980template <
class FUNCTOR,
class ITERATOR>
983 const TransformIterator<FUNCTOR, ITERATOR>& rhs)
985 return lhs.iterator() >= rhs.iterator();
988template <
class FUNCTOR,
class ITERATOR>
991 TransformIterator<FUNCTOR, ITERATOR>& iterator,
994 return TransformIterator<FUNCTOR, ITERATOR>(iterator.iterator()++,
998template <
class FUNCTOR,
class ITERATOR>
1001 TransformIterator<FUNCTOR, ITERATOR>& iterator,
1004 return TransformIterator<FUNCTOR, ITERATOR>(iterator.iterator()--,
1005 iterator.functor());
1008template <
class FUNCTOR,
class ITERATOR>
1011 const TransformIterator<FUNCTOR, ITERATOR>& iterator,
1012 typename TransformIterator<FUNCTOR, ITERATOR>::difference_type offset)
1014 return TransformIterator<FUNCTOR, ITERATOR>(iterator.iterator() + offset,
1015 iterator.functor());
1018template <
class FUNCTOR,
class ITERATOR>
1021 typename TransformIterator<FUNCTOR, ITERATOR>::difference_type offset,
1022 const TransformIterator<FUNCTOR, ITERATOR>& iterator)
1024 return TransformIterator<FUNCTOR, ITERATOR>(iterator.iterator() + offset,
1025 iterator.functor());
1028template <
class FUNCTOR,
class ITERATOR>
1031 const TransformIterator<FUNCTOR, ITERATOR>& iterator,
1032 typename TransformIterator<FUNCTOR, ITERATOR>::difference_type offset)
1034 return TransformIterator<FUNCTOR, ITERATOR>(iterator.iterator() - offset,
1035 iterator.functor());
1038template <
class FUNCTOR,
class ITERATOR>
1042 const TransformIterator<FUNCTOR, ITERATOR>& b)
1044 return a.iterator() - b.iterator();
1048template <
class FUNCTOR,
class ITERATOR>
1050void bdlb::swap(TransformIterator<FUNCTOR, ITERATOR>& a,
1051 TransformIterator<FUNCTOR, ITERATOR>& b)
1054 swap(a.functor(), b.functor());
1055 swap(a.iterator(), b.iterator());
1065template <
class FUNCTOR,
class ITERATOR>
1068 const ITERATOR& iterator,
1069 const FUNCTOR& functor,
1073 iterator, functor, basicAllocator);
Forward declaration.
Definition bslstl_function.h:934
Definition bslalg_constructorproxy.h:368
Definition bslma_allocator.h:457
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
void swap(OptionValue &a, OptionValue &b)
Definition bdlb_algorithmworkaroundutil.h:74
bool operator!=(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
TransformIterator< FUNCTOR, ITERATOR > operator--(TransformIterator< FUNCTOR, ITERATOR > &iterator, int)
bool operator>=(const Guid &lhs, const Guid &rhs)
FunctionOutputIterator< FUNCTION > & operator++(FunctionOutputIterator< FUNCTION > &iterator)
Do nothing and return specified iterator.
Definition bdlb_functionoutputiterator.h:405
void swap(NullableAllocatedValue< TYPE > &a, NullableAllocatedValue< TYPE > &b)
TransformIterator< FUNCTOR, ITERATOR > operator+(const TransformIterator< FUNCTOR, ITERATOR > &iterator, typename TransformIterator< FUNCTOR, ITERATOR >::difference_type offset)
bool operator<=(const Guid &lhs, const Guid &rhs)
bool operator>(const Guid &lhs, const Guid &rhs)
TransformIterator< FUNCTOR, ITERATOR > operator-(const TransformIterator< FUNCTOR, ITERATOR > &iterator, typename TransformIterator< FUNCTOR, ITERATOR >::difference_type offset)
bool operator<(const Guid &lhs, const Guid &rhs)
bool operator==(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
Definition bslmf_conditional.h:120
Definition bslmf_integralconstant.h:244
Definition bslmf_isreference.h:137
Definition bslmf_removecv.h:118
Definition bslma_usesbslmaallocator.h:343
t_FALLBACK type
Definition bslmf_resulttype.h:260
static TYPE * addressOf(TYPE &obj)
Definition bsls_util.h:305