www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
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++ - Template related ICE

↑ ↓ ← "Matthew Wilson" <dmd synesis.com.au> writes:
Walter

Receive the following:

  Internal error: template 3726
  --- errorlevel 1

when the operator <() for lhs = simple_string, rhs = char_type const *

The actual function is defined as

template<   ss_typename_param_k C
        ,   ss_typename_param_k T
        ,   ss_typename_param_k A
        >
inline ss_bool_t operator <(basic_simple_string<C, T, A> const &lhs,
                                          ss_typename_type_k
basic_simple_string<C, T, A>::char_type const *rhs)
{
    return lhs.compare(rhs) < 0;
}

I built in a workaround for this some months ago in a couple of other
classes, and was a bit stupid in forgetting it. The workaround is:

template<   ss_typename_param_k C
        ,   ss_typename_param_k T
        ,   ss_typename_param_k A
        >
inline ss_bool_t operator <(basic_simple_string<C, T, A> const &lhs,
#ifdef __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT
                                          ss_typename_type_k
basic_simple_string<C, T, A>::char_type const *rhs)
#else
                                          C const *rhs)
#endif /* __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT */
{
    return lhs.compare(rhs) < 0;
}

Nevertheless, this is a compiler error, so though you'd want to know (and
fix)

Matthew
Feb 07 2003
↑ ↓ "Walter" <walter digitalmars.com> writes:
Can you give me a complete test case? Thanks, -Walter

"Matthew Wilson" <dmd synesis.com.au> wrote in message
news:b21m9f$5pj$1 digitaldaemon.com...
 Walter

 Receive the following:

   Internal error: template 3726
   --- errorlevel 1

 when the operator <() for lhs = simple_string, rhs = char_type const *

 The actual function is defined as

 template<   ss_typename_param_k C
         ,   ss_typename_param_k T
         ,   ss_typename_param_k A
         >
 inline ss_bool_t operator <(basic_simple_string<C, T, A> const &lhs,
                                           ss_typename_type_k
 basic_simple_string<C, T, A>::char_type const *rhs)
 {
     return lhs.compare(rhs) < 0;
 }

 I built in a workaround for this some months ago in a couple of other
 classes, and was a bit stupid in forgetting it. The workaround is:

 template<   ss_typename_param_k C
         ,   ss_typename_param_k T
         ,   ss_typename_param_k A
         >
 inline ss_bool_t operator <(basic_simple_string<C, T, A> const &lhs,
 #ifdef __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT
                                           ss_typename_type_k
 basic_simple_string<C, T, A>::char_type const *rhs)
 #else
                                           C const *rhs)
 #endif /* __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT */
 {
     return lhs.compare(rhs) < 0;
 }

 Nevertheless, this is a compiler error, so though you'd want to know (and
 fix)

 Matthew

Feb 07 2003
↑ ↓ "Matthew Wilson" <dmd synesis.com.au> writes:
Will do

"Walter" <walter digitalmars.com> wrote in message
news:b24fkk$1jj8$1 digitaldaemon.com...
 Can you give me a complete test case? Thanks, -Walter

 "Matthew Wilson" <dmd synesis.com.au> wrote in message
 news:b21m9f$5pj$1 digitaldaemon.com...
 Walter

 Receive the following:

   Internal error: template 3726
   --- errorlevel 1

 when the operator <() for lhs = simple_string, rhs = char_type const *

 The actual function is defined as

 template<   ss_typename_param_k C
         ,   ss_typename_param_k T
         ,   ss_typename_param_k A
         >
 inline ss_bool_t operator <(basic_simple_string<C, T, A> const &lhs,
                                           ss_typename_type_k
 basic_simple_string<C, T, A>::char_type const *rhs)
 {
     return lhs.compare(rhs) < 0;
 }

 I built in a workaround for this some months ago in a couple of other
 classes, and was a bit stupid in forgetting it. The workaround is:

 template<   ss_typename_param_k C
         ,   ss_typename_param_k T
         ,   ss_typename_param_k A
         >
 inline ss_bool_t operator <(basic_simple_string<C, T, A> const &lhs,
 #ifdef __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT
                                           ss_typename_type_k
 basic_simple_string<C, T, A>::char_type const *rhs)
 #else
                                           C const *rhs)
 #endif /* __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT */
 {
     return lhs.compare(rhs) < 0;
 }

 Nevertheless, this is a compiler error, so though you'd want to know


 fix)

 Matthew


Feb 08 2003
↑ ↓ "Matthew Wilson" <dmd synesis.com.au> writes:
Here goes


 template <typename V>
 class cls
 {
 public:
  typedef V   value_type;
  typedef cls<V>  class_type;
 };

 template <typename V>
 #if 1
 inline bool operator ==(cls<V>::class_type const &lhs, cls<V>::value_type
const &rhs)
 #else
 inline bool operator ==(cls<V> const &lhs, V const &rhs)
 #endif /* 0 */
 {
  return false;
 }

 int main()
 {
  typedef cls<int>  cls_t;

  cls_t c1;
  int   i1;

  if(c1 == i1)
  {}

  return 0;
 }


If you change the #if 1 to #if 0 it works fine. As is, it gives

  Internal error: template 3726
  --- errorlevel 1

Matthew


"Matthew Wilson" <dmd synesis.com.au> wrote in message
news:b24fo3$1jkh$1 digitaldaemon.com...
 Will do

 "Walter" <walter digitalmars.com> wrote in message
 news:b24fkk$1jj8$1 digitaldaemon.com...
 Can you give me a complete test case? Thanks, -Walter

 "Matthew Wilson" <dmd synesis.com.au> wrote in message
 news:b21m9f$5pj$1 digitaldaemon.com...
 Walter

 Receive the following:

   Internal error: template 3726
   --- errorlevel 1

 when the operator <() for lhs = simple_string, rhs = char_type const *

 The actual function is defined as

 template<   ss_typename_param_k C
         ,   ss_typename_param_k T
         ,   ss_typename_param_k A
         >
 inline ss_bool_t operator <(basic_simple_string<C, T, A> const &lhs,
                                           ss_typename_type_k
 basic_simple_string<C, T, A>::char_type const *rhs)
 {
     return lhs.compare(rhs) < 0;
 }

 I built in a workaround for this some months ago in a couple of other
 classes, and was a bit stupid in forgetting it. The workaround is:

 template<   ss_typename_param_k C
         ,   ss_typename_param_k T
         ,   ss_typename_param_k A
         >
 inline ss_bool_t operator <(basic_simple_string<C, T, A> const &lhs,
 #ifdef __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT
                                           ss_typename_type_k
 basic_simple_string<C, T, A>::char_type const *rhs)
 #else
                                           C const *rhs)
 #endif /* __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT */
 {
     return lhs.compare(rhs) < 0;
 }

 Nevertheless, this is a compiler error, so though you'd want to know


 fix)

 Matthew



Feb 08 2003
↑ ↓ → "Walter" <walter digitalmars.com> writes:
Thanks!
Feb 09 2003