48 #if !defined(THEOLIZER_INTERNAL_RBFOR_H) 49 #define THEOLIZER_INTERNAL_RBFOR_H 64 #pragma warning(disable:4100) 71 #ifndef THEOLIZER_INTERNAL_DOXYGEN 81 template<
class tRBForAdaptor>
84 typedef typename tRBForAdaptor::Range Range;
85 tRBForAdaptor& mRBForAdaptor;
87 RBForReferencer(tRBForAdaptor& iRBForAdaptor) : mRBForAdaptor(iRBForAdaptor)
95 mRBForAdaptor.drop_front();
97 bool operator!=(RBForReferencer
const& iRhs)
const 99 return !mRBForAdaptor.empty();
107 template<
class tRange,
class tIterator,
class tNextFunc>
108 class RBForAdaptor :
private tRange
113 RBForAdaptor(tIterator&& iBegin, tIterator&& iEnd, tNextFunc
const& iNextFunc) :
114 tRange(std::forward<tIterator>(iBegin), std::forward<tIterator>(iEnd)),
119 template<
class>
friend class internal::RBForReferencer;
120 typedef tRange Range;
121 typedef internal::RBForReferencer<RBForAdaptor> RBForReferencer;
124 mNextFunc(tRange::front());
125 tRange::drop_front();
129 tRange& getRange() {
return *
this;}
132 RBForReferencer begin() {
return RBForReferencer(*
this);}
133 RBForReferencer end() {
return RBForReferencer(*
this);}
146 void operator()(...) { }
149 #endif // THEOLIZER_INTERNAL_DOXYGEN 160 template<
class tIterator>
164 std::remove_reference<decltype(*(std::declval<tIterator>()))>::type ValueType;
172 mBegin(std::forward<tIterator>(iBegin)),
173 mEnd (std::forward<tIterator>(iEnd))
182 throw std::out_of_range(
"BasicRange::drop_front()");
189 ValueType&
front() {
return *mBegin;}
193 bool empty()
const {
return mBegin == mEnd;}
197 tIterator
begin()
const {
return mBegin;}
201 tIterator
end()
const {
return mEnd;}
235 #ifndef THEOLIZER_INTERNAL_DOXYGEN 237 template<
class tIterator>
242 Indexer(tIterator&& iBegin, tIterator&& iEnd) :
245 std::forward<tIterator>(iBegin),
246 std::forward<tIterator>(iEnd)
255 std::size_t getIndex()
const {
return mIndex;}
259 Indexer& operator++()
267 Indexer operator++(
int)
281 template<
class tIterator>
class tRange,
283 class tNextFunc=internal::NopFunctor
285 class MakeRBForAdaptor
287 typedef decltype(std::begin(std::declval<tContainer>())) Iterator;
288 typedef typename std::remove_reference<tNextFunc>::type NextFunc;
290 typedef RBForAdaptor<tRange<Iterator>, Iterator, NextFunc> Type;
293 #endif // THEOLIZER_INTERNAL_DOXYGEN 308 template<
class tIterator>
class tRange,
310 class tNextFunc=internal::NopFunctor
312 auto getRBForAdaptor(tContainer&& iContainer, tNextFunc&& iNextFunc=internal::NopFunctor()) ->
313 typename internal::MakeRBForAdaptor<tRange, tContainer, tNextFunc>::Type
315 typedef decltype(getRBForAdaptor<tRange>(iContainer, iNextFunc)) RBForAdaptor;
316 return RBForAdaptor(std::begin(iContainer), std::end(iContainer), iNextFunc);
325 template<
class tContainer,
class tNextFunc=
internal::NopFunctor>
326 auto getRBForSeparator(tContainer&& iContainer, tNextFunc&& iNextFunc=internal::NopFunctor()) ->
327 typename internal::MakeRBForAdaptor<BasicRange, tContainer, tNextFunc>::Type
329 return getRBForAdaptor<BasicRange>(iContainer, iNextFunc);
338 template<
class tContainer,
class tNextFunc=
internal::NopFunctor>
339 auto getRBForIndexer(tContainer&& iContainer, tNextFunc&& iNextFunc=internal::NopFunctor()) ->
340 typename internal::MakeRBForAdaptor<internal::Indexer, tContainer, tNextFunc>::Type
342 return getRBForAdaptor<internal::Indexer>(iContainer, iNextFunc);
359 #endif // THEOLIZER_INTERNAL_BASE_H
BasicRange(tIterator &&iBegin, tIterator &&iEnd)
auto getRBForIndexer(tContainer &&iContainer, tNextFunc &&iNextFunc=internal::NopFunctor()) -> typename internal::MakeRBForAdaptor< internal::Indexer, tContainer, tNextFunc >::Type
範囲ベースforを分割できるようにし、かつ、インデックス番号用レンジ生成
BasicRange & operator++()
BasicRange operator++(int)
auto getRBForSeparator(tContainer &&iContainer, tNextFunc &&iNextFunc=internal::NopFunctor()) -> typename internal::MakeRBForAdaptor< BasicRange, tContainer, tNextFunc >::Type
範囲ベースforを分割できるようにするためのレンジ生成
auto getRBForAdaptor(tContainer &&iContainer, tNextFunc &&iNextFunc=internal::NopFunctor()) -> typename internal::MakeRBForAdaptor< tRange, tContainer, tNextFunc >::Type
汎用の範囲ベースfor用レンジ生成