Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
July 12, 2002 Koenig lookup failure with templates | ||||
---|---|---|---|---|
| ||||
Attachments: | 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 with >sc templ_tt.cpp templ_tt.cpp(79) : Error: 'true_typedef' is not a class template 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 fine >sc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp link templ_tt,,,user32+kernel32/noi; 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 |
July 12, 2002 Re: Koenig lookup failure with templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | 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 for > generating strong ("true") typedefs. When compiled, as included, 8.28 fails > with > > >sc templ_tt.cpp > templ_tt.cpp(79) : Error: 'true_typedef' is not a class template > 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 fine > > >sc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp > link templ_tt,,,user32+kernel32/noi; > > 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 > > > > > > > |
July 14, 2002 Re: Koenig lookup failure with templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 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 > > with > > > > >sc templ_tt.cpp > > templ_tt.cpp(79) : Error: 'true_typedef' is not a class template > > 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 fine > > > > >sc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp > > link templ_tt,,,user32+kernel32/noi; > > > > 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 > > > > > > > > > > > > > > > > |
July 14, 2002 Re: Koenig lookup failure with templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 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 > > with > > > > >sc templ_tt.cpp > > templ_tt.cpp(79) : Error: 'true_typedef' is not a class template > > 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 fine > > > > >sc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp > > link templ_tt,,,user32+kernel32/noi; > > > > 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 > > > > > > > > > > > > > > > > |
July 15, 2002 Re: Koenig lookup failure with templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | 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 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 > > > with > > > > > > >sc templ_tt.cpp > > > templ_tt.cpp(79) : Error: 'true_typedef' is not a class template > > > 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 fine > > > > > > >sc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp > > > link templ_tt,,,user32+kernel32/noi; > > > > > > 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 > > > > > > > > > > > > > > > > > > > > > > > > > > > |
July 15, 2002 Re: Koenig lookup failure with templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 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 > > 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 > > > > with > > > > > > > > >sc templ_tt.cpp > > > > templ_tt.cpp(79) : Error: 'true_typedef' is not a class template > > > > 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 fine > > > > > > > > >sc -D_STLSOFT_NO_NAMESPACES templ_tt.cpp > > > > link templ_tt,,,user32+kernel32/noi; > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
July 15, 2002 Re: Koenig lookup failure with templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | 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 ++ out > of the stlsoft namespace, no? > > :) > > Matthew |
July 15, 2002 Re: Koenig lookup failure with templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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! 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 ++ > out > > of the stlsoft namespace, no? > > > > :) > > > > Matthew > > > |
July 16, 2002 Re: Koenig lookup failure with templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | "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. |
Copyright © 1999-2021 by the D Language Foundation