|
Boost Users : |
Subject: [Boost-users] variant iterator, operators and enable_if
From: MM (finjulhich_at_[hidden])
Date: 2012-03-01 16:58:19
Hi,
I have a variant iterator, ie an iterator that is associated with a variant,
this variant is over a list of different iterators types.
The variant object holds at any time 1 of the possible iterators.
The variant iterator class attempts to implement the Iterator concept of
c++1x.
I am trying to declare and then define the various possible versions of
operator== for instance.
I have declared:
bool operator==( const variant_iterator& lhs, const variant_iterator&
rhs );
so far so good.
I also want to allow == between the variant_iterator and any of the iterator
types the variant type contains.
So I am writing a:
template <typename contained_iter_t>
bool operator==(const variant_iterator& lhs, const contained_iter_t& rhs
);
1. Will the non templated version of operator== always take precedence over
the templated one when in the same namespace/scope?
2. Do I need to disable the templated version when contained_iter_t happens
to be variant_iterator ?
3. I want to allow comparison with both the straight and reverse versions of
the iterator types in the variant.
I have set a mpl container of iterators, made a variant off that container,
then I use enable_if to check if the "contained_iterator" is part of the mpl
container for Iterators, in which case I implement == with a == between the
bound type and the iterator, otherwise between the bounded type and the base
of the reverse iterator.
all the enable_if are used as the return type for the operator==
there are 4 versions: lhs==rhs and rhs==lhs for Iterator and
reverse_iterator
Comments and suggestions on the idea are appreciated,
MM
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net