edouarda / brigand

Instant compile time C++ 11 metaprogramming library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reverse_range API is error-prone

jfalcou opened this issue · comments

MSVC 2015 U2 and MinGW g++ 5.1 seems affected

FYI, calling reverse on range does not exhibit the issue.

What's the bug exactly, you do range on which kind of collection?

Nah, I'm stupid. reverse_range also reverse its input (reverse_range<10,0>) and I was calling reverse_range<0,10>. Maybe we shoudl fix this API issue.

I thought the same thing last night :)

Indeed, we should, it's an easy fix.

I'm not sure it's error prone, because I think it's easier to understand that

reverse_range<int, 10, 5> gives "10, 9, 8, 7, 6"

than

reverse_range<int, 5, 10> gives "10, 9, 8, 7, 6"

Then can't we shove the current impl in detail:: and have range<T,A,B> checks if A > B to select the implementation so range<int,10,5> and range<int,5,10> do what we think ?

It's easy to do, but I think it's confusing. Maybe a static assert to prevent mixing the inputs?

@jfalcou if you are ok with it I will close the issue.

I like x down to y notation and I think a static_assert should be enough.

static_assert and be done with it. I don't think this needs to be SFINAE friendly.

Fine by me, I will do that today.