Topic: Not intuitive, but is it right?


Author: dent@highway1.com.au (Andy Dent)
Date: 1997/10/14
Raw View
In article <739184349wnr@ma.ccngroup.com>, aGriffiths@ma.ccngroup.com wrote:

>What is not intuitive
>is that having discovered the template is inapplicable that an error
>is generated, rather than excluding the template from consideration.

Sigh

I've run into similar problems with CodeWarrior. I suspect therefore that
the changed matching rules in the standard will continue to make life
harder.

I too found it very uninintuitive!

--
Andy Dent, Software Designer, A.D. Software, Western Australia
OOFILE - Database, reports, GUI for c++ on Mac, Unix & Windows
http://www.highway1.com.au/adsoftware/
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: aGriffiths@ma.ccngroup.com (Alan Griffiths)
Date: 1997/10/06
Raw View
The following code snippet gives errors in MSVC5 (patch level2).  I
can relate to why the compiler might be considering resolving the
equivalence operator against various templated versions (they are
visible in the current scope and a user defined conversion is
required to bind to the basic int euqivalence.  What is not intuitive
is that having discovered the template is inapplicable that an error
is generated, rather than excluding the template from consideration.

Code:


#include <string>

using namespace std;


class MBase {};


template<class Type> class MDerived_template : public MBase
{
    public:
  virtual operator const Type&() const = 0;
};  // This is line 13 (but cause is below)


bool f(MDerived_template<int>& value)
{
    return 666 == value;
// D:\test\msvc5\msvc5-bug6.cpp(13) : error C2784:
//    'bool __cdecl std::operator ==
//    (const class std::basic_string<`template-parameter-1',
//    `template-parameter-2',`template-parameter-3'> &,
//    const template-parameter-1 *)' :
//    could not deduce template argument for
//    'const class std::basic_string<`template-parameter-1',
//    `template-parameter-2',`template-parameter-3'> &' from 'const int'
// (several more of the same)
}
__
Alan Griffiths              | Senior Systems Consultant, Experian (Formerly CCN)
alan.griffiths@experian.com (agriffiths@ma.ccngroup.com, Tel. +44 115 934 4517)
(ACCU C++ SIG organiser     | <http://www.accu.org/> alan@octopull.demon.co.uk)
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]