
N2930, Range-Based For Loop Wording (Without Concepts), provides begin() and end() non-member function templates for standard library types. It also provides general range access non-member templates: // 24.7 range access [iterator.range] template<typename C> auto begin(C& c) -> decltype(c.begin()); template<typename C> auto begin(const C& c) -> decltype(c.begin()); template<typename C> auto end(C& c) -> decltype(c.end()); template<typename C> auto end(const C& c) -> decltype(c.end()); template<typename T, size_t N> T* begin(T (&array)[N]); template<typename T, size_t N> T* end(T (&array)[N]); (Until the official WG21 site gets updated, you can see a copy of n2930 at http://mysite.verizon.net/beman/n2930.html) Should Boost.Range and/or RangeEx be modified and/or extended in light of N2930? Can Boost.Range, RangeEx, or some other Boost component help developers and users who want to take advantage of N2930 in C++03 now, and do so in a way that transitions smoothly to C++0x as language and library available? --Beman

Beman Dawes wrote:
N2930, Range-Based For Loop Wording (Without Concepts), provides begin() and end() non-member function templates for standard library types. It also provides general range access non-member templates:
// 24.7 range access [iterator.range] template<typename C> auto begin(C& c) -> decltype(c.begin()); template<typename C> auto begin(const C& c) -> decltype(c.begin()); template<typename C> auto end(C& c) -> decltype(c.end()); template<typename C> auto end(const C& c) -> decltype(c.end()); template<typename T, size_t N> T* begin(T (&array)[N]); template<typename T, size_t N> T* end(T (&array)[N]);
(Until the official WG21 site gets updated, you can see a copy of n2930 at http://mysite.verizon.net/beman/n2930.html)
Should Boost.Range and/or RangeEx be modified and/or extended in light of N2930?
Such functions are not defined very differently in Boost.Range. I believe they are defined like this: template<typename C> typename range_iterator<C>::type begin(C&); template<typename C> typename range_iterator<const C>::type begin(const C&); with template<typename C> struct range_iterator { typedef typename C::iterator type; }; template<typename C> struct range_iterator<const C> { typedef typename C::const_iterator type; }; Is it really worth it to remove dependency over iterator and const_iterator member types? I guess it would be possible to change the definition of range_iterator to use decltype((*(C*)0).begin()) otherwise.

Beman Dawes skrev:
N2930, Range-Based For Loop Wording (Without Concepts), provides begin() and end() non-member function templates for standard library types. It also provides general range access non-member templates:
// 24.7 range access [iterator.range] template<typename C> auto begin(C& c) -> decltype(c.begin()); template<typename C> auto begin(const C& c) -> decltype(c.begin()); template<typename C> auto end(C& c) -> decltype(c.end()); template<typename C> auto end(const C& c) -> decltype(c.end()); template<typename T, size_t N> T* begin(T (&array)[N]); template<typename T, size_t N> T* end(T (&array)[N]);
(Until the official WG21 site gets updated, you can see a copy of n2930 at http://mysite.verizon.net/beman/n2930.html)
Should Boost.Range and/or RangeEx be modified and/or extended in light of N2930?
Maybe. I always imagined that the availability of decltype + auto + perfect forwarding should be used to simplify the library somewhat. Once implementations start to ship the new standard lib components, we could start to do like boost::swap, calling std::begin/std::end internally.
Can Boost.Range, RangeEx, or some other Boost component help developers and users who want to take advantage of N2930 in C++03 now, and do so in a way that transitions smoothly to C++0x as language and library available?
Doing like the above, seems to be the right thing to do. We really want boost::begin/boost::end to be customization points. -Thorsten
participants (3)
-
Beman Dawes
-
Mathias Gaunard
-
Thorsten Ottosen