[iterators] Missing typedefs in v1.57
I posted this a week ago in the user mailing list but it went unnoticed. Perhaps this developers' list is a better place to post it. The typedefs for difference_type and reference used to be in scope for classes derived from iterator_facade. Since v1.57 they have to be declared thus: typedef typename iterator_facade_::difference_type difference_type; typedef typename iterator_facade_::reference reference; This seems out of place for a class that was designed to reduce boiler plate code. However, if the change was intentional, please document it. Thanks, Keith MacDonald
On Tuesday 09 December 2014 10:43:11 news.gmane.org wrote:
I posted this a week ago in the user mailing list but it went unnoticed. Perhaps this developers' list is a better place to post it.
The typedefs for difference_type and reference used to be in scope for classes derived from iterator_facade. Since v1.57 they have to be declared thus:
typedef typename iterator_facade_::difference_type difference_type; typedef typename iterator_facade_::reference reference;
This seems out of place for a class that was designed to reduce boiler plate code. However, if the change was intentional, please document it.
I'm not sure what you mean. The typedefs are in the base class of iterator_facade and are public. As such they are accessible to the derived classes. Can you elaborate what the problem is?
Class iterator_facade has been refactored in v1.57 such that most of its
functionality is now in iterator_facade_base. This includes the typedefs
for difference_type and reference. Hence, my classes which are derived from
iterator_facade now have to declare them. For example:
template
I posted this a week ago in the user mailing list but it went unnoticed. Perhaps this developers' list is a better place to post it.
The typedefs for difference_type and reference used to be in scope for classes derived from iterator_facade. Since v1.57 they have to be declared thus:
typedef typename iterator_facade_::difference_type difference_type; typedef typename iterator_facade_::reference reference;
This seems out of place for a class that was designed to reduce boiler plate code. However, if the change was intentional, please document it.
I'm not sure what you mean. The typedefs are in the base class of iterator_facade and are public. As such they are accessible to the derived classes. Can you elaborate what the problem is? _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
On Tue, Dec 9, 2014 at 11:08 PM, news.gmane.org
Class iterator_facade has been refactored in v1.57 such that most of its functionality is now in iterator_facade_base. This includes the typedefs for difference_type and reference. Hence, my classes which are derived from iterator_facade now have to declare them. For example:
template
class char_iter : public boost::iterators::iterator_facade< char_iter , Value, boost::iterators::random_access_traversal_tag, Value, Size > { public: typedef typename iterator_facade_::difference_type difference_type; typedef typename iterator_facade_::reference reference; ... };
Have I misunderstood how to do this?
Your class is a template, and iterator_facade specialization depends on the template parameters. The compiler does not bind names from the iterator_facade base class (because it doesn't know which specialization will be taken), so you must explicitly qualify the base class name or declare the convenience typedefs like above. By doing so you make the type names dependent on the template parameters, postponing name binding to the template instantiation stage. This is also true for the iterator_facade_ typedef, as well as other members of iterator_facade, BTW. This behavior is standard C++, and 1.57 didn't bring anything new in this respect. Some compilers do not perform name binding properly, effectively delaying all of it to the template instantiation point. This is not a conforming behavior, and it can let errors like this pass unnoticed.
Some compilers do not perform name binding properly, effectively delaying all of it to the template instantiation point. This is not a conforming behavior, and it can let errors like this pass unnoticed.
I had reported this issue as well and afaik Visual Studio 2010 does not handle non dependent name look-up in dependent base class correctly: template <typename T> struct Base { typedef T Type; int m_n; }; template <typename T> struct DerivedT : public Base<T> { void Foo() { //illegal code accepted by VS2010? #if 1 Type t; m_n = 0; #else typename Base<T>::Type t; //make name dependent this->m_n = 0; #endif } }; Somehow with the old Boost (1.52) iterator_facade using the reference type directly in derived class was accepted by Visual Studio 2010 while the new code is (correctly) rejected. Anyway i am not a template magician, so may be this gives a clue.
Thanks for the clarification.
"Andrey Semashev" wrote in message
news:CAEhD+6D7xRSZi0dQXwfFwM3h7ofgoOH5yjfa_0VeHRjAGYTHMg@mail.gmail.com...
On Tue, Dec 9, 2014 at 11:08 PM, news.gmane.org
Class iterator_facade has been refactored in v1.57 such that most of its functionality is now in iterator_facade_base. This includes the typedefs for difference_type and reference. Hence, my classes which are derived from iterator_facade now have to declare them. For example:
template
class char_iter : public boost::iterators::iterator_facade< char_iter , Value, boost::iterators::random_access_traversal_tag, Value, Size > { public: typedef typename iterator_facade_::difference_type difference_type; typedef typename iterator_facade_::reference reference; ... };
Have I misunderstood how to do this?
Your class is a template, and iterator_facade specialization depends on the template parameters. The compiler does not bind names from the iterator_facade base class (because it doesn't know which specialization will be taken), so you must explicitly qualify the base class name or declare the convenience typedefs like above. By doing so you make the type names dependent on the template parameters, postponing name binding to the template instantiation stage. This is also true for the iterator_facade_ typedef, as well as other members of iterator_facade, BTW. This behavior is standard C++, and 1.57 didn't bring anything new in this respect. Some compilers do not perform name binding properly, effectively delaying all of it to the template instantiation point. This is not a conforming behavior, and it can let errors like this pass unnoticed. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
Andrey Semashev
-
gast128
-
news.gmane.org