On Wed, Sep 3, 2014 at 9:54 AM, Agustín K-ballo Bergé
On 03/09/2014 01:39 p.m., Robert Ramey wrote:
So far I haven't seen anyone propose an example which benefits from the original proposal. Seems to me a solution to a non-existent problem.
Purely pseudocode, but I believe the intention of the proposal is to be able to do things like:
template< class InputIt, class Distance > void advance( InputIt& it, Distance n ) { static_if(is_random_access_iterator<InputIt>()) { it +=n; } static_else { /*increment/decrement it in a loop*/ } }
...without having to resort to SFINAE-d overloads nor tag dispatching, given that `it += n` is not required to compile for iterators whose category is weaker than random access.
Sure, for example:
template< typename Iter, typename Dist >
void myadvance ( Iter& i, Dist n ) {
Iter* p = &i;
static_if