c++ - Koenig lookup failure with templates
- "Matthew Wilson" <matthew thedjournal.com> Jul 11 2002
- "Walter" <walter digitalmars.com> Jul 12 2002
- "Matthew Wilson" <matthew thedjournal.com> Jul 14 2002
- "Walter" <walter digitalmars.com> Jul 14 2002
- "Matthew Wilson" <matthew thedjournal.com> Jul 14 2002
- "Walter" <walter digitalmars.com> Jul 15 2002
- "Matthew Wilson" <matthew thedjournal.com> Jul 15 2002
- "Walter" <walter digitalmars.com> Jul 15 2002
- "Matthew Wilson" <matthew thedjournal.com> Jul 14 2002
Walter, a template bug for you, which I found when trying it out on one of the STLSoft classes. Included is an extract (templ_tt.cpp) from stlsoft_true_typedef.h (the original can be found at http://stlsoft.org), which is a template class for generating strong ("true") typedefs. When compiled, as included, 8.28 fails withsc templ_tt.cpp
templ_tt.cpp(83) : Error: 'v' is not in function parameter list templ_tt.cpp(85) : Error: '=', ';' or ',' expected templ_tt.cpp(86) : Error: '=', ';' or ',' expected return 0; ^ templ_tt.cpp(105) : Error: '=', ';' or ',' expected Fatal error: too many errors --- errorlevel 1 When compiled with namespaces suspended it works finesc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp
It appears that Koenig lookup is kind of right, in that the compiler locates the operator, but then loses the original context. I've included a non-template version (non_templ_tt.cpp) which demonstrates that it is indeed the templates that are introducing the confusion. Have fun. :) Matthew
Jul 11 2002
I haven't implemented Koenig lookup rules yet :-( "Matthew Wilson" <matthew thedjournal.com> wrote in message news:agls97$seh$1 digitaldaemon.com...Walter, a template bug for you, which I found when trying it out on one of the STLSoft classes. Included is an extract (templ_tt.cpp) from stlsoft_true_typedef.h (the original can be found at http://stlsoft.org), which is a template class
generating strong ("true") typedefs. When compiled, as included, 8.28
withsc templ_tt.cpp
templ_tt.cpp(83) : Error: 'v' is not in function parameter list templ_tt.cpp(85) : Error: '=', ';' or ',' expected templ_tt.cpp(86) : Error: '=', ';' or ',' expected return 0; ^ templ_tt.cpp(105) : Error: '=', ';' or ',' expected Fatal error: too many errors --- errorlevel 1 When compiled with namespaces suspended it works finesc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp
It appears that Koenig lookup is kind of right, in that the compiler
the operator, but then loses the original context. I've included a non-template version (non_templ_tt.cpp) which demonstrates that it is indeed the templates that are introducing the confusion. Have fun. :) Matthew
Jul 12 2002
But you must have something similar, since the non-template version works correctly. Or am I being dumb? (Note: the probability of this in the general case is greater than 82.73%, and in this specific case 82.77%) "Walter" <walter digitalmars.com> wrote in message news:agm45p$15l5$1 digitaldaemon.com...I haven't implemented Koenig lookup rules yet :-( "Matthew Wilson" <matthew thedjournal.com> wrote in message news:agls97$seh$1 digitaldaemon.com...Walter, a template bug for you, which I found when trying it out on one
the STLSoft classes. Included is an extract (templ_tt.cpp) from stlsoft_true_typedef.h (the original can be found at http://stlsoft.org), which is a template class
generating strong ("true") typedefs. When compiled, as included, 8.28
withsc templ_tt.cpp
templ_tt.cpp(83) : Error: 'v' is not in function parameter list templ_tt.cpp(85) : Error: '=', ';' or ',' expected templ_tt.cpp(86) : Error: '=', ';' or ',' expected return 0; ^ templ_tt.cpp(105) : Error: '=', ';' or ',' expected Fatal error: too many errors --- errorlevel 1 When compiled with namespaces suspended it works finesc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp
It appears that Koenig lookup is kind of right, in that the compiler
the operator, but then loses the original context. I've included a non-template version (non_templ_tt.cpp) which
that it is indeed the templates that are introducing the confusion. Have fun. :) Matthew
Jul 14 2002
Koenig lookup only applies to namespaces, so that's why it worked without namespaces. "Matthew Wilson" <matthew thedjournal.com> wrote in message news:agt0av$3md$1 digitaldaemon.com...But you must have something similar, since the non-template version works correctly. Or am I being dumb? (Note: the probability of this in the general case is greater than 82.73%, and in this specific case 82.77%) "Walter" <walter digitalmars.com> wrote in message news:agm45p$15l5$1 digitaldaemon.com...I haven't implemented Koenig lookup rules yet :-( "Matthew Wilson" <matthew thedjournal.com> wrote in message news:agls97$seh$1 digitaldaemon.com...Walter, a template bug for you, which I found when trying it out on
ofthe STLSoft classes. Included is an extract (templ_tt.cpp) from stlsoft_true_typedef.h (the original can be found at http://stlsoft.org), which is a template
forgenerating strong ("true") typedefs. When compiled, as included, 8.28
withsc templ_tt.cpp
templ_tt.cpp(83) : Error: 'v' is not in function parameter list templ_tt.cpp(85) : Error: '=', ';' or ',' expected templ_tt.cpp(86) : Error: '=', ';' or ',' expected return 0; ^ templ_tt.cpp(105) : Error: '=', ';' or ',' expected Fatal error: too many errors --- errorlevel 1 When compiled with namespaces suspended it works finesc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp
It appears that Koenig lookup is kind of right, in that the compiler
the operator, but then loses the original context. I've included a non-template version (non_templ_tt.cpp) which
that it is indeed the templates that are introducing the confusion. Have fun. :) Matthew
Jul 14 2002
That's not what I said. I mentioned that it worked with KL in the non-template version, not the non-namespace version. The non-template version is thus: /* ///////////////////////////////////////////////////////////// * * ... * * Extract from stlsoft_true_typedef.h * * www: http://www.synesis.com.au/stlsoft * http://www.stlsoft.org/ * * Copyright (C) 2002, Synesis Software Pty Ltd. * (Licensed under the Synesis Software Standard Source License: * http://www.synesis.com.au/licenses/ssssl.html) * * ... * * ////////////////////////////////////////////////////////// */ namespace stlsoft { class int_true_typedef { typedef int value_type; public: int_true_typedef(const value_type &value) : m_value(value) {} const value_type base_type_value() const { return m_value; } protected: value_type m_value; }; inline const int_true_typedef operator ++(int_true_typedef &v, int) { return int_true_typedef(v.base_type_value() + 1); } } int main(int /* argc */, char ** /* argv */) { typedef stlsoft::int_true_typedef Intint_true_typedef; Intint_true_typedef ic1(23); Intint_true_typedef ic2 = ic1++; return 0; } so you can see that there are still namespaces involved, and it must be doing some kind of (Koenig-like) lookup in order to get the operator ++ out of the stlsoft namespace, no? :) Matthew "Walter" <walter digitalmars.com> wrote in message news:agtc2p$equ$1 digitaldaemon.com...Koenig lookup only applies to namespaces, so that's why it worked without namespaces. "Matthew Wilson" <matthew thedjournal.com> wrote in message news:agt0av$3md$1 digitaldaemon.com...But you must have something similar, since the non-template version
correctly. Or am I being dumb? (Note: the probability of this in the general case
greater than 82.73%, and in this specific case 82.77%) "Walter" <walter digitalmars.com> wrote in message news:agm45p$15l5$1 digitaldaemon.com...I haven't implemented Koenig lookup rules yet :-( "Matthew Wilson" <matthew thedjournal.com> wrote in message news:agls97$seh$1 digitaldaemon.com...Walter, a template bug for you, which I found when trying it out on
ofthe STLSoft classes. Included is an extract (templ_tt.cpp) from stlsoft_true_typedef.h
original can be found at http://stlsoft.org), which is a template
forgenerating strong ("true") typedefs. When compiled, as included,
failswithsc templ_tt.cpp
templ_tt.cpp(83) : Error: 'v' is not in function parameter list templ_tt.cpp(85) : Error: '=', ';' or ',' expected templ_tt.cpp(86) : Error: '=', ';' or ',' expected return 0; ^ templ_tt.cpp(105) : Error: '=', ';' or ',' expected Fatal error: too many errors --- errorlevel 1 When compiled with namespaces suspended it works finesc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp
It appears that Koenig lookup is kind of right, in that the compiler
the operator, but then loses the original context. I've included a non-template version (non_templ_tt.cpp) which
that it is indeed the templates that are introducing the confusion. Have fun. :) Matthew
Jul 14 2002
Sorry I read what I expected to see and not what you'd actually written! And the answer is I don't know at the moment. The namespace implementation isn't right, and I'm going to immerse myself in fixing all the namespace bugs after I get the template stuff all up to speed. It's the only way I have a hope of getting this stuff done. "Matthew Wilson" <matthew thedjournal.com> wrote in message news:agtgqi$j34$1 digitaldaemon.com...That's not what I said. I mentioned that it worked with KL in the non-template version, not the non-namespace version. The non-template version is thus: /* ///////////////////////////////////////////////////////////// * * ... * * Extract from stlsoft_true_typedef.h * * www: http://www.synesis.com.au/stlsoft * http://www.stlsoft.org/ * * Copyright (C) 2002, Synesis Software Pty Ltd. * (Licensed under the Synesis Software Standard Source License: * http://www.synesis.com.au/licenses/ssssl.html) * * ... * * ////////////////////////////////////////////////////////// */ namespace stlsoft { class int_true_typedef { typedef int value_type; public: int_true_typedef(const value_type &value) : m_value(value) {} const value_type base_type_value() const { return m_value; } protected: value_type m_value; }; inline const int_true_typedef operator ++(int_true_typedef &v, int) { return int_true_typedef(v.base_type_value() + 1); } } int main(int /* argc */, char ** /* argv */) { typedef stlsoft::int_true_typedef Intint_true_typedef; Intint_true_typedef ic1(23); Intint_true_typedef ic2 = ic1++; return 0; } so you can see that there are still namespaces involved, and it must be doing some kind of (Koenig-like) lookup in order to get the operator ++
of the stlsoft namespace, no? :) Matthew
Jul 15 2002
No worries. I shall look forward to giving you lots more material. :) "Walter" <walter digitalmars.com> wrote in message news:agtvdt$14n5$1 digitaldaemon.com...Sorry I read what I expected to see and not what you'd actually written!
the answer is I don't know at the moment. The namespace implementation
right, and I'm going to immerse myself in fixing all the namespace bugs after I get the template stuff all up to speed. It's the only way I have a hope of getting this stuff done. "Matthew Wilson" <matthew thedjournal.com> wrote in message news:agtgqi$j34$1 digitaldaemon.com...That's not what I said. I mentioned that it worked with KL in the non-template version, not the non-namespace version. The non-template version is thus: /* ///////////////////////////////////////////////////////////// * * ... * * Extract from stlsoft_true_typedef.h * * www: http://www.synesis.com.au/stlsoft * http://www.stlsoft.org/ * * Copyright (C) 2002, Synesis Software Pty Ltd. * (Licensed under the Synesis Software Standard Source License: * http://www.synesis.com.au/licenses/ssssl.html) * * ... * * ////////////////////////////////////////////////////////// */ namespace stlsoft { class int_true_typedef { typedef int value_type; public: int_true_typedef(const value_type &value) : m_value(value) {} const value_type base_type_value() const { return m_value; } protected: value_type m_value; }; inline const int_true_typedef operator ++(int_true_typedef &v, int) { return int_true_typedef(v.base_type_value() + 1); } } int main(int /* argc */, char ** /* argv */) { typedef stlsoft::int_true_typedef Intint_true_typedef; Intint_true_typedef ic1(23); Intint_true_typedef ic2 = ic1++; return 0; } so you can see that there are still namespaces involved, and it must be doing some kind of (Koenig-like) lookup in order to get the operator ++
of the stlsoft namespace, no? :) Matthew
Jul 15 2002
"Matthew Wilson" <matthew thedjournal.com> wrote in message news:agvj7t$2rk0$1 digitaldaemon.com...No worries. I shall look forward to giving you lots more material. :)
I know that writing a good bug report is hard work, but they are much appreciated. After they are fixed, they also wind up in the test suite so they stay fixed.
Jul 15 2002
Is this slated for attention in a soon-to-be-released version? "Walter" <walter digitalmars.com> wrote in message news:agm45p$15l5$1 digitaldaemon.com...I haven't implemented Koenig lookup rules yet :-( "Matthew Wilson" <matthew thedjournal.com> wrote in message news:agls97$seh$1 digitaldaemon.com...Walter, a template bug for you, which I found when trying it out on one
the STLSoft classes. Included is an extract (templ_tt.cpp) from stlsoft_true_typedef.h (the original can be found at http://stlsoft.org), which is a template class
generating strong ("true") typedefs. When compiled, as included, 8.28
withsc templ_tt.cpp
templ_tt.cpp(83) : Error: 'v' is not in function parameter list templ_tt.cpp(85) : Error: '=', ';' or ',' expected templ_tt.cpp(86) : Error: '=', ';' or ',' expected return 0; ^ templ_tt.cpp(105) : Error: '=', ';' or ',' expected Fatal error: too many errors --- errorlevel 1 When compiled with namespaces suspended it works finesc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp
It appears that Koenig lookup is kind of right, in that the compiler
the operator, but then loses the original context. I've included a non-template version (non_templ_tt.cpp) which
that it is indeed the templates that are introducing the confusion. Have fun. :) Matthew
Jul 14 2002









"Walter" <walter digitalmars.com> 