On 5/5/2015 12:07 PM, Stefan Ram wrote:
> Victor Bazarov <v.ba...@comcast.invalid> writes:
>> I hope you're not going to ask next why pointers and arrays don't have
>> members like 'cbegin' or 'rend'...
>
> Well, for arrays ...
>
> #include <iostream>
> #include <ostream>
> #include <memory>
> #include <vector>
>
> int main()
> { ::std::cout << __cplusplus << '\n';
> ::std::vector< int >a{ 1, 2, 3 };
> for( auto p = ::std::cbegin( a ); p != ::std::cend( a ); ++p )
Yes, but those are not *members*.
> ::std::cout << *p << '\n'; }
>
> 201402
> 1
> 2
> 3
>
> And all of a sudden, it also works with initializer lists!
>
> My problem was actually that I did not manage before to force
> my compiler into C++14 mode before!
>
> #include <iostream>
> #include <ostream>
> #include <memory>
> #include <initializer_list>
>
> int main()
> { ::std::cout << __cplusplus << '\n';
> ::std::initializer_list< int >a{ 1, 2, 3 };
> for( auto p = ::std::cbegin( a ); p != ::std::cend( a ); ++p )
> ::std::cout << *p << '\n'; }
>
> 201402
> 1
> 2
> 3