[counting_range] why?
Ok, maybe I'm having a senior moment here, but why is the second line wrong?
Thx, Rob.
#include
On Wed, Nov 28, 2012 at 9:17 AM, Robert Jones
Ok, maybe I'm having a senior moment here, but why is the second line wrong?
Thx, Rob.
#include
int main( ) { // Ok auto r = boost::counting_range( 0, 3 );
// Not Ok. auto s = boost::counting_range<int>( 0, 3 ); }
Looks okay to me. How is it wrong? Compiler error? What compiler, what version of Boost, and what's the error? - Jeff
Here's the compiler output....
|| ~/local/gcc-4.6.2/bin/g++ -std=c++0x -I ~/local/boost_1_48_0/include -g
-W -fno-strict-aliasing -fno-inline -Wno-uninitialized -Wcast-align
-Wwrite-strings -Wnon-virtual-dtor -Wextra -c -o range_for.o range_for.cpp
In file included from
/home/rjones/local/boost_1_48_0/include/boost/iterator/iterator_categories.hpp|15|
0,
|| from
/home/rjones/local/boost_1_48_0/include/boost/iterator/detail/facade_iterator_category.hpp:7,
|| from
/home/rjones/local/boost_1_48_0/include/boost/iterator/iterator_facade.hpp:14,
|| from
/home/rjones/local/boost_1_48_0/include/boost/range/iterator_range_core.hpp:23,
|| from
/home/rjones/local/boost_1_48_0/include/boost/range/counting_range.hpp:18,
|| from range_for.cpp:1:
|| /home/rjones/local/boost_1_48_0/include/boost/mpl/eval_if.hpp: In
instantiation of ‘boost::mpl::eval_if_c ’:
/home/rjones/local/boost_1_48_0/include/boost/range/iterator.hpp|63 col 63|
instantiated from ‘boost::range_iterator<const int>’
/home/rjones/local/boost_1_48_0/include/boost/range/value_type.hpp|30 col
12| instantiated from ‘boost::range_value<const int>’
range_for.cpp|9 col 47| instantiated from here
/home/rjones/local/boost_1_48_0/include/boost/mpl/eval_if.hpp|60 col 31|
error: no type named ‘type’ in ‘boost::mpl::eval_if_c
On Wed, Nov 28, 2012 at 9:41 AM, Robert Jones
Here's the compiler output....
|| ~/local/gcc-4.6.2/bin/g++ -std=c++0x -I ~/local/boost_1_48_0/include -g -W -fno-strict-aliasing -fno-inline -Wno-uninitialized -Wcast-align -Wwrite-strings -Wnon-virtual-dtor -Wextra -c -o range_for.o range_for.cpp In file included from /home/rjones/local/boost_1_48_0/include/boost/iterator/iterator_categories.hpp|15| 0, || from /home/rjones/local/boost_1_48_0/include/boost/iterator/detail/facade_iterator_category.hpp:7, || from /home/rjones/local/boost_1_48_0/include/boost/iterator/iterator_facade.hpp:14, || from /home/rjones/local/boost_1_48_0/include/boost/range/iterator_range_core.hpp:23, || from /home/rjones/local/boost_1_48_0/include/boost/range/counting_range.hpp:18, || from range_for.cpp:1: || /home/rjones/local/boost_1_48_0/include/boost/mpl/eval_if.hpp: In instantiation of ‘boost::mpl::eval_if_c
’: /home/rjones/local/boost_1_48_0/include/boost/range/iterator.hpp|63 col 63| instantiated from ‘boost::range_iterator<int>’ /home/rjones/local/boost_1_48_0/include/boost/range/value_type.hpp|30 col 12| instantiated from ‘boost::range_value<int>’ range_for.cpp|9 col 47| instantiated from here /home/rjones/local/boost_1_48_0/include/boost/mpl/eval_if.hpp|60 col 31| error: no type named ‘type’ in ‘boost::mpl::eval_if_c ::f_ {aka struct boost::range_mutable_iterator<int>}’ || /home/rjones/local/boost_1_48_0/include/boost/mpl/eval_if.hpp: In instantiation of ‘boost::mpl::eval_if_c ’: /home/rjones/local/boost_1_48_0/include/boost/range/iterator.hpp|63 col 63| instantiated from ‘boost::range_iterator<const int>’ /home/rjones/local/boost_1_48_0/include/boost/range/value_type.hpp|30 col 12| instantiated from ‘boost::range_value<const int>’ range_for.cpp|9 col 47| instantiated from here /home/rjones/local/boost_1_48_0/include/boost/mpl/eval_if.hpp|60 col 31| error: no type named ‘type’ in ‘boost::mpl::eval_if_c
Looks like gcc is instantiating the unary overloads of counting_range (with template parameter int) even though you're supplying 2 arguments...I'm not sure if that is standard behavior or not; MSVC9 seems to do okay with it. Is this is a real hindrance or merely curiosity? - Jeff
On Wed, Nov 28, 2012 at 5:56 PM, Jeffrey Lee Hellrung, Jr. < jeffrey.hellrung@gmail.com> wrote:
Looks like gcc is instantiating the unary overloads of counting_range (with template parameter int) even though you're supplying 2 arguments...I'm not sure if that is standard behavior or not; MSVC9 seems to do okay with it.
Is this is a real hindrance or merely curiosity?
More curiosity now, as I can do what I need to do, but where I started from was... counting_range<unsigned>( 0, 3 ) So using arguments of type int, in a range of type unsigned, which doesn't work. I can of course do counting_range( 0U, 3U ) to get the same effect, but it's a bit inelegant! I haven't investigated what counting_range( 0U, 3 ) does! Thx, Rob.
On Wed, Nov 28, 2012 at 10:05 AM, Robert Jones
On Wed, Nov 28, 2012 at 5:56 PM, Jeffrey Lee Hellrung, Jr. < jeffrey.hellrung@gmail.com> wrote:
Looks like gcc is instantiating the unary overloads of counting_range (with template parameter int) even though you're supplying 2 arguments...I'm not sure if that is standard behavior or not; MSVC9 seems to do okay with it.
Is this is a real hindrance or merely curiosity?
More curiosity now, as I can do what I need to do, but where I started from was...
counting_range<unsigned>( 0, 3 )
So using arguments of type int, in a range of type unsigned, which doesn't work. I can of course do
counting_range( 0U, 3U )
to get the same effect, but it's a bit inelegant!
I haven't investigated what counting_range( 0U, 3 ) does!
Probably won't work :) Sounds like your initial use case *should* be okay (seems to work on clang and msvc) and your version of gcc is incorrect in rejecting it. Consider reducing your use case down to be Boost-independent and filing a bug with gcc. - Jeff
On Nov 28, 2012, at 9:36 AM, "Jeffrey Lee Hellrung, Jr."
On Wed, Nov 28, 2012 at 9:17 AM, Robert Jones
wrote: Ok, maybe I'm having a senior moment here, but why is the second line wrong? Thx, Rob.
#include
int main( ) { // Ok auto r = boost::counting_range( 0, 3 );
// Not Ok. auto s = boost::counting_range<int>( 0, 3 ); }
Looks okay to me. How is it wrong? Compiler error? What compiler, what version of Boost, and what's the error?
Compiles fine for me with clang. -- Marshall Marshall Clow Idio Software mailto:mclow.lists@gmail.com A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait). -- Yu Suzuki
participants (3)
-
Jeffrey Lee Hellrung, Jr.
-
Marshall Clow
-
Robert Jones