Archives
D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger
C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows
digitalmars.empire
digitalmars.DMDScript
|
c++ - Koenig lookup failure with templates
↑ ↓ ← → "Matthew Wilson" <matthew thedjournal.com> writes:
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(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
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
↑ ↓ ← → "Walter" <walter digitalmars.com> writes:
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
with
sc 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 fine
sc -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
↑ ↓ ← → "Matthew Wilson" <matthew thedjournal.com> writes:
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
with
sc 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 fine
sc -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
↑ ↓ ← → "Walter" <walter digitalmars.com> writes:
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
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
for
generating strong ("true") typedefs. When compiled, as included, 8.28
with
sc 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 fine
sc -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
↑ ↓ ← → "Matthew Wilson" <matthew thedjournal.com> writes:
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
of
the 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
for
generating strong ("true") typedefs. When compiled, as included,
fails
with
sc 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 fine
sc -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
↑ ↓ ← → "Walter" <walter digitalmars.com> writes:
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
↑ ↓ ← → "Matthew Wilson" <matthew thedjournal.com> writes:
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
↑ ↓ ← → "Walter" <walter digitalmars.com> writes:
"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.
↑ ↓ ← → "Matthew Wilson" <matthew thedjournal.com> writes:
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
with
sc 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 fine
sc -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
|
|