
"Peter Dimov" <pdimov@mmltd.net> wrote in message news:007301c55654$256e3bb0$6401a8c0@pdimov2... | Thorsten Ottosen wrote: | > "Anthony Williams" <anthony_w.geo@yahoo.com> wrote in message | > news:fywten01.fsf@yahoo.com... | >> If the implementation uses free standing functions, you need to | >> write begin() and end() for your type. If the implementation uses | >> members, you can write make_range() for your type, *or* write the | >> members. | > | > yep, but the latter approach is harder and takes just about twice as | > much code in C++0x. | | Can you elaborate, please? sure. as a free-standing function we can say template< class T > auto begin( MyType<T>&& r ) -> decltype( r.Begin() ) { return r.Begin(); } for( const auto& r : my_obj ) { ... } with an adapter class we need to say struct my_type_adapter { MyType& ref; my_type_adapter( MyType&& r ) : ref(r) { } decltype( ref.Begin() ) begin() { return ref.Begin(); } }; for( const auto& r : my_type_adapter( my_obj ) ) { ... } or something. -Thorsten