1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
|
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2018, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Rene Rahn <rene.rahn@fu-berlin.de>
// ==========================================================================
#ifndef INCLUDE_SEQAN_BASIC_ITERATOR_ZIP_H_
#define INCLUDE_SEQAN_BASIC_ITERATOR_ZIP_H_
#include <tuple>
namespace seqan
{
// ============================================================================
// Forwards
// ============================================================================
// This function enables us to use the initializer-list trick to expand a parameter pack,
// in order to call a function on each element of the parameter pack.
template <typename T>
inline void
_seqanUnpackFunc(std::initializer_list<T> const /*unused*/)
{}
// This macro is used to hide wrapping the function call as an initializer-list.
#define SEQAN_UNPACK_FUNC(f) _seqanUnpackFunc({(f, 0)...})
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
// Traits to hold the indices of the corresponding tuple.
template <unsigned... >
struct IndexSequence
{};
// Tag to determine the zip iterator.
struct ZipIterator_;
typedef Tag<ZipIterator_> ZipIterator;
/*!
* @class ZipIterator
*
* @extends Iter
* @implements IteratorAssociatedTypesConcept
*
* @headerfile <seqan/basic.h>
*
* @brief Zips multiple iterators over different containers into a single iterator.
*
* @signature class Iter<std::tuple<TIteratorTypes...>, ZipIterator>;
*
* @tparam TIteratorTypes A template parameter pack with one or more @link ContainerConcept#Iterator @endlink types.
*
* This iterator ties together different iterator types for different containers of the same size.
* It allows one to operate on a single iterator, if multiple containers need to be traversed simultaneously.
* Note, that all operations are still executed in a serial fashion.
* If the zip iterator is dereferenced it returns a <a href="http://en.cppreference.com/w/cpp/utility/tuple">std::tuple</a>
* containing the dereferenced values of all embedded iterators.
* The metafunctions @link Value @endlink, @link GetValue @endlink and @link Reference @endlink
* are overloaded accordingly.
*
* To easily create a zip iterator one can use the helper function @link makeZipIterator @endlink.
*
* @section Example
*
* The following example demonstrates the function of the zip iterator:
*
* @include demos/dox/basic/zip_iterator.cpp
*
* This outputs the following to the console:
* @include demos/dox/basic/zip_iterator.cpp.stdout
*
* @note Throws an assertion if <tt>sizeof...(TIteratorTypes) == 0</tt> is true.
*/
template <typename... TIteratorPack>
class Iter<std::tuple<TIteratorPack...>, ZipIterator>
{
public:
std::tuple<TIteratorPack...> dataIter; // tuple stores the different iterators.
/*!
* @fn ZipIterator#ZipIterator
* @brief Constructor.
* @signature Iter()
* Iter(TIteratorTypes... args)
*
* @param args The iterator instances to create the @link ZipIterator @endlink from. Default constructors are not listed.
*/
// Default c'tor.
Iter()
{
static_assert(sizeof...(TIteratorPack) > 0, "Requires at least one argument!");
}
// Custom c'tor to create from iterator pack
Iter(TIteratorPack... iterPack) : dataIter(std::make_tuple(iterPack...))
{}
};
// ============================================================================
// Metafunctions
// ============================================================================
// ----------------------------------------------------------------------------
// Metafunction MakeIndexSequence
// ----------------------------------------------------------------------------
// This metafunction recursively calls itself, while adding a new index to the growing
// Indices pack.
template<unsigned ID, unsigned... Indices>
struct MakeIndexSequence :
MakeIndexSequence<ID-1, ID-1, Indices...>
{};
// Base case to stop the recursion and to define the IndexSequence with the indices pack.
template<unsigned... Indices>
struct MakeIndexSequence<0, Indices...>
{
typedef IndexSequence<Indices...> Type;
};
// ----------------------------------------------------------------------------
// Metafunction Container
// ----------------------------------------------------------------------------
/*!
* @mfn ZipIterator#Container
* @headerfile <seqan/basic.h>
* @brief Retruns the Container type of the @link ZipIterator @endlink.
*
* @signature typename Container<TZipIterator>::Type;
*
* @tparam TZipIterator The type of the @link ZipIterator @endlink.
*
* @return TRes A <a href="http://en.cppreference.com/w/cpp/utility/tuple">std::tuple</a> containing the container
* types of all iterator types embedded in the <tt>TZipIterator</tt> type.
*/
template <typename... TIteratorPack>
struct Container<Iter<std::tuple<TIteratorPack...>, ZipIterator> >
{
typedef std::tuple<typename Container<TIteratorPack>::Type...> Type;
};
// ----------------------------------------------------------------------------
// Metafunction Value
// ----------------------------------------------------------------------------
// We expand each iterator type in the param pack to call its Value metafunction
// and define a tuple with the value types.
/*!
* @mfn ZipIterator#Value
* @headerfile <seqan/basic.h>
* @brief Retruns the Value type of the @link ZipIterator @endlink.
*
* @signature typename Value<TZipIterator>::Type;
*
* @tparam TZipIterator The type of the @link ZipIterator @endlink.
*
* @return TRes A <a href="http://en.cppreference.com/w/cpp/utility/tuple">std::tuple</a> containing the value
* types of all iterator types embedded in the <tt>TZipIterator</tt> type.
*/
template <typename... TIteratorPack>
struct Value<Iter<std::tuple<TIteratorPack...>, ZipIterator> >
{
typedef std::tuple<typename Value<TIteratorPack>::Type...> Type;
};
// ----------------------------------------------------------------------------
// Metafunction GetValue
// ----------------------------------------------------------------------------
/*!
* @mfn ZipIterator#GetValue
* @headerfile <seqan/basic.h>
* @brief Retruns the GetValue type of the @link ZipIterator @endlink.
*
* @signature typename GetValue<TZipIterator>::Type;
*
* @tparam TZipIterator The type of the @link ZipIterator @endlink.
*
* @return TRes A <a href="http://en.cppreference.com/w/cpp/utility/tuple">std::tuple</a> containing the value
* types of all iterator types embedded in the <tt>TZipIterator</tt> type.
*/
template <typename... TIteratorPack>
struct GetValue<Iter<std::tuple<TIteratorPack...>, ZipIterator> >
{
typedef std::tuple<typename GetValue<TIteratorPack>::Type...> Type;
};
// ----------------------------------------------------------------------------
// Metafunction Reference
// ----------------------------------------------------------------------------
/*!
* @mfn ZipIterator#Reference
* @headerfile <seqan/basic.h>
* @brief Retruns the Reference type of the @link ZipIterator @endlink.
*
* @signature typename GetValue<TZipIterator>::Type;
*
* @tparam TZipIterator The type of the @link ZipIterator @endlink.
*
* @return TRes A <a href="http://en.cppreference.com/w/cpp/utility/tuple">std::tuple</a> containing the value
* types of all iterator types embedded in the <tt>TZipIterator</tt> type.
*/
template <typename... TIteratorPack>
struct Reference<Iter<std::tuple<TIteratorPack...>, ZipIterator> >
{
typedef std::tuple<typename Reference<TIteratorPack>::Type...> Type;
};
// Unclear why we need that! It should be possible to let the generic implementation
// in iterator_base.h to take care of it. Apparently, it is the same semantic.
template <typename... TIteratorPack>
struct Reference<Iter<std::tuple<TIteratorPack...>, ZipIterator> const> :
Reference<Iter<std::tuple<TIteratorPack...>, ZipIterator> > {};
// ----------------------------------------------------------------------------
// Metafunction Size
// ----------------------------------------------------------------------------
// The size type is only defined by the first type as only the first iterator
// is used to determine the difference between two iterators.
template <typename TFirst, typename... TIteratorPack>
struct Size<Iter<std::tuple<TFirst, TIteratorPack...>, ZipIterator> >
{
typedef typename Size<TFirst>::Type Type; // The position and size is determined only by the first argument in the tuple.
};
// Use the default Position-MF
// ----------------------------------------------------------------------------
// Metafunction Difference
// ----------------------------------------------------------------------------
// We use only the first iterator to determine the difference.
template <typename TFirst, typename... TIteratorPack>
struct Difference<Iter<std::tuple<TFirst, TIteratorPack...>, ZipIterator> >
{
typedef typename Difference<TFirst>::Type Type; // The difference is determined by only the first argument in the tuple.
};
// ============================================================================
// Functions
// ============================================================================
namespace impl
{
// ----------------------------------------------------------------------------
// Function impl::increment
// ----------------------------------------------------------------------------
// private increment interface.
// Uses the initializer-trick to apply the ++operator to all elements in the tuple
// using pack expansion.
template <typename... TIteratorPack, unsigned... INDEX_SEQUENCE>
inline void
increment(std::tuple<TIteratorPack...> & me,
IndexSequence<INDEX_SEQUENCE...> const)
{
SEQAN_UNPACK_FUNC(++std::get<INDEX_SEQUENCE>(me));
}
// ----------------------------------------------------------------------------
// Function impl::decrement
// ----------------------------------------------------------------------------
// Same here for decrement.
template <typename... TIteratorPack, unsigned... INDEX_SEQUENCE>
inline void
decrement(std::tuple<TIteratorPack...> & me,
IndexSequence<INDEX_SEQUENCE...> const)
{
SEQAN_UNPACK_FUNC(--std::get<INDEX_SEQUENCE>(me));
}
// ----------------------------------------------------------------------------
// Function impl::advance
// ----------------------------------------------------------------------------
// ... and for advancing the iterator.
template <typename... TIteratorPack, unsigned... INDICES, typename TIntegral>
inline void
advance(std::tuple<TIteratorPack...> & me,
IndexSequence<INDICES...> const,
TIntegral const steps)
{
SEQAN_UNPACK_FUNC(std::advance(std::get<INDICES>(me), steps));
}
// ----------------------------------------------------------------------------
// Function impl::dereference
// ----------------------------------------------------------------------------
// Dereference each iterator in the tuple and forward return values as tuple.
template <typename... TIteratorPack, unsigned... INDEX_SEQUENCE>
inline auto
dereference(std::tuple<TIteratorPack...> & me,
IndexSequence<INDEX_SEQUENCE...> const) -> decltype(std::forward_as_tuple(*std::get<INDEX_SEQUENCE>(me)...))
{
return std::forward_as_tuple(*std::get<INDEX_SEQUENCE>(me)...);
}
template <typename... TIteratorPack, unsigned... INDEX_SEQUENCE>
inline auto
dereference(std::tuple<TIteratorPack...> const & me,
IndexSequence<INDEX_SEQUENCE...> const) -> decltype(std::forward_as_tuple(*std::get<INDEX_SEQUENCE>(me)...))
{
return std::forward_as_tuple(*std::get<INDEX_SEQUENCE>(me)...);
}
// ----------------------------------------------------------------------------
// Function impl::assignValue
// ----------------------------------------------------------------------------
// Dereference each iterator in the tuple and forward return values as tuple.
template <typename... TRefPack, typename... TValuePack, unsigned... INDEX_SEQUENCE>
inline void
assignValue(std::tuple<TRefPack...> targetPack,
std::tuple<TValuePack...> const & sourcePack,
IndexSequence<INDEX_SEQUENCE...> const)
{
SEQAN_UNPACK_FUNC(assign(std::get<INDEX_SEQUENCE>(targetPack), std::get<INDEX_SEQUENCE>(sourcePack)));
}
// ----------------------------------------------------------------------------
// Function impl::moveValue
// ----------------------------------------------------------------------------
// Dereference each iterator in the tuple and forward return values as tuple.
template <typename... TRefPack, typename... TValuePack, unsigned... INDEX_SEQUENCE>
inline void
moveValue(std::tuple<TRefPack...> targetPack,
std::tuple<TValuePack...> const & sourcePack,
IndexSequence<INDEX_SEQUENCE...> const)
{
SEQAN_UNPACK_FUNC(move(std::get<INDEX_SEQUENCE>(targetPack), std::get<INDEX_SEQUENCE>(sourcePack)));
}
} // namespace impl
// ----------------------------------------------------------------------------
// Function operator*
// ----------------------------------------------------------------------------
template <typename... TIteratorPack>
inline typename Reference<Iter<std::tuple<TIteratorPack...>, ZipIterator> >::Type
operator*(Iter<std::tuple<TIteratorPack...>, ZipIterator> & me)
{
return impl::dereference(me.dataIter, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type());
}
template <typename... TIteratorPack>
inline typename Reference<Iter<std::tuple<TIteratorPack...>, ZipIterator> const>::Type
operator*(Iter<std::tuple<TIteratorPack...>, ZipIterator> const & me)
{
return impl::dereference(me.dataIter, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type());
}
// ----------------------------------------------------------------------------
// Function operator++; pre-increment
// ----------------------------------------------------------------------------
template <typename... TIteratorPack>
inline Iter<std::tuple<TIteratorPack...>, ZipIterator> &
operator++(Iter<std::tuple<TIteratorPack...>, ZipIterator> & me /*pre-increment*/)
{
impl::increment(me.dataIter, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type());
return me;
}
// ----------------------------------------------------------------------------
// Function operator++; post-increment
// ----------------------------------------------------------------------------
template <typename... TIteratorPack>
inline Iter<std::tuple<TIteratorPack...>, ZipIterator>
operator++(Iter<std::tuple<TIteratorPack...>, ZipIterator> & me, int const /*post-increment*/)
{
typename std::remove_reference<decltype(me)>::type tmp(me);
impl::increment(me.dataIter, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type());
return tmp;
}
// ----------------------------------------------------------------------------
// Function operator+
// ----------------------------------------------------------------------------
template <typename... TIteratorPack, typename TIntegral>
inline Iter<std::tuple<TIteratorPack...>, ZipIterator>
operator+(Iter<std::tuple<TIteratorPack...>, ZipIterator> me,
TIntegral const steps)
{
impl::advance(me.dataIter,
typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type(),
steps);
return me;
}
template <typename... TIteratorPack, typename TIntegral>
inline Iter<std::tuple<TIteratorPack...>, ZipIterator>
operator+(TIntegral const steps,
Iter<std::tuple<TIteratorPack...>, ZipIterator> me)
{
impl::advance(me.dataIter,
typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type(),
steps);
return me;
}
// ----------------------------------------------------------------------------
// Function operator+=
// ----------------------------------------------------------------------------
template <typename... TIteratorPack, typename TIntegral>
inline Iter<std::tuple<TIteratorPack...>, ZipIterator> &
operator+=(Iter<std::tuple<TIteratorPack...>, ZipIterator> & me,
TIntegral const steps)
{
impl::advance(me.dataIter,
typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type(),
steps);
return me;
}
// ----------------------------------------------------------------------------
// Function operator--; pre-increment
// ----------------------------------------------------------------------------
template <typename... TIteratorPack>
inline Iter<std::tuple<TIteratorPack...>, ZipIterator>&
operator--(Iter<std::tuple<TIteratorPack...>, ZipIterator> & me /*pre-increment*/)
{
impl::decrement(me.dataIter, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type());
return me;
}
// ----------------------------------------------------------------------------
// Function operator--; post-increment
// ----------------------------------------------------------------------------
template <typename... TIteratorPack>
inline Iter<std::tuple<TIteratorPack...>, ZipIterator>
operator--(Iter<std::tuple<TIteratorPack...>, ZipIterator> & me, int const /*post-increment*/)
{
typename std::remove_reference<decltype(me)>::type tmp(me);
impl::decrement(me.dataIter, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type());
return tmp;
}
// ----------------------------------------------------------------------------
// Function operator-
// ----------------------------------------------------------------------------
template <typename... TIteratorPack, typename TIntegral>
inline Iter<std::tuple<TIteratorPack...>, ZipIterator>
operator-(Iter<std::tuple<TIteratorPack...>, ZipIterator> me,
TIntegral const steps)
{
typedef typename MakeSigned<TIntegral>::Type TSigned;
impl::advance(me.dataIter, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type(),
-static_cast<TSigned>(steps));
return me;
}
template <typename... TIteratorPack>
inline typename Difference<Iter<std::tuple<TIteratorPack...>, ZipIterator> >::Type
operator-(Iter<std::tuple<TIteratorPack...>, ZipIterator> const & lhs,
Iter<std::tuple<TIteratorPack...>, ZipIterator> const & rhs)
{
return std::get<0>(lhs.dataIter) - std::get<0>(rhs.dataIter);
}
// ----------------------------------------------------------------------------
// Function operator-=
// ----------------------------------------------------------------------------
template <typename... TIteratorPack, typename TIntegral>
inline Iter<std::tuple<TIteratorPack...>, ZipIterator> &
operator-=(Iter<std::tuple<TIteratorPack...>, ZipIterator> & me,
TIntegral const steps)
{
typedef typename MakeSigned<TIntegral>::Type TSigned;
impl::advance(me.dataIter, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type(),
-static_cast<TSigned>(steps));
return me;
}
// ----------------------------------------------------------------------------
// Function operator==
// ----------------------------------------------------------------------------
template <typename... TIteratorPackL, typename... TIteratorPackR>
inline bool
operator==(Iter<std::tuple<TIteratorPackL...>, ZipIterator> const & lhs,
Iter<std::tuple<TIteratorPackR...>, ZipIterator> const & rhs)
{
return lhs.dataIter == rhs.dataIter;
}
// ----------------------------------------------------------------------------
// Function operator!=
// ----------------------------------------------------------------------------
template <typename... TIteratorPackL, typename... TIteratorPackR>
inline bool
operator!=(Iter<std::tuple<TIteratorPackL...>, ZipIterator> const & lhs,
Iter<std::tuple<TIteratorPackR...>, ZipIterator> const & rhs)
{
return lhs.dataIter != rhs.dataIter;
}
// ----------------------------------------------------------------------------
// Function operator>=
// ----------------------------------------------------------------------------
template <typename... TIteratorPackL, typename... TIteratorPackR>
inline bool
operator>=(Iter<std::tuple<TIteratorPackL...>, ZipIterator> const & lhs,
Iter<std::tuple<TIteratorPackR...>, ZipIterator> const & rhs)
{
return lhs.dataIter >= rhs.dataIter;
}
// ----------------------------------------------------------------------------
// Function operator>
// ----------------------------------------------------------------------------
template <typename... TIteratorPackL, typename... TIteratorPackR>
inline bool
operator>(Iter<std::tuple<TIteratorPackL...>, ZipIterator> const & lhs,
Iter<std::tuple<TIteratorPackR...>, ZipIterator> const & rhs)
{
return lhs.dataIter > rhs.dataIter;
}
// ----------------------------------------------------------------------------
// Function operator<=
// ----------------------------------------------------------------------------
template <typename... TIteratorPackL, typename... TIteratorPackR>
inline bool
operator<=(Iter<std::tuple<TIteratorPackL...>, ZipIterator> const & lhs,
Iter<std::tuple<TIteratorPackR...>, ZipIterator> const & rhs)
{
return lhs.dataIter <= rhs.dataIter;
}
// ----------------------------------------------------------------------------
// Function operator<
// ----------------------------------------------------------------------------
template <typename... TIteratorPackL, typename... TIteratorPackR>
inline bool
operator<(Iter<std::tuple<TIteratorPackL...>, ZipIterator> const & lhs,
Iter<std::tuple<TIteratorPackR...>, ZipIterator> const & rhs)
{
return lhs.dataIter < rhs.dataIter;
}
// ----------------------------------------------------------------------------
// Function swap()
// ----------------------------------------------------------------------------
template <typename... TIteratorPack>
inline void
swap(Iter<std::tuple<TIteratorPack...>, ZipIterator> & lhs,
Iter<std::tuple<TIteratorPack...>, ZipIterator> & rhs)
{
std::swap(lhs.dataIter, rhs.dataIter);
}
// ----------------------------------------------------------------------------
// Function assignValue()
// ----------------------------------------------------------------------------
template <typename... TIteratorPack, typename... TValuePack>
inline void
assignValue(Iter<std::tuple<TIteratorPack...>, ZipIterator> & target,
std::tuple<TValuePack...> const & value)
{
static_assert(sizeof...(TIteratorPack) == sizeof...(TValuePack), "Wrong number of arguments.");
impl::assignValue(*target, value, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type());
}
// ----------------------------------------------------------------------------
// Function moveValue()
// ----------------------------------------------------------------------------
template <typename... TIteratorPack, typename... TValuePack>
inline void
moveValue(Iter<std::tuple<TIteratorPack...>, ZipIterator> & target,
std::tuple<TValuePack...> const & value)
{
static_assert(sizeof...(TIteratorPack) == sizeof...(TValuePack), "Wrong number of arguments.");
impl::moveValue(*target, value, typename MakeIndexSequence<sizeof...(TIteratorPack)>::Type());
}
// ----------------------------------------------------------------------------
// Function makeZipIterator()
// ----------------------------------------------------------------------------
/*!
* @fn makeZipIterator
* @headerfile <seqan/basic_iterator.h>
* @brief Creates a @link ZipIterator @endlink, deducing the iterator types from the arguments.
*
* @signature iter makeZipIterator(TIteratorTypes... args)
*
* @param [in] args One or more iterator instances to construct the @link ZipIterator @endlink from.
*
* @return iter A @link ZipIterator @endlink containing the given iterator instances.
*/
template <typename... TIteratorPack>
inline Iter<std::tuple<TIteratorPack... >, ZipIterator>
makeZipIterator(TIteratorPack... iterPack)
{
return Iter<std::tuple<TIteratorPack... >, ZipIterator>(iterPack...);
}
}
#endif // #ifndef INCLUDE_SEQAN_BASIC_ITERATOR_ZIP_H_
|