H
Henrik Ullerichs
The following gives you two bugs.
Just create a default console project, and paste it at the bottom of the file with _tmain.
e:\Src\C\BlobHolderTest\BlobHolderTest.cpp(44) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 2701)
e:\Src\C\BlobHolderTest\BlobHolderTest.cpp(49) : error C2914: 'makeConstObject' : cannot deduce template argument as
function argument is ambiguous
e:\Src\C\BlobHolderTest\BlobHolderTest.cpp(49) : error C2784: 'void makeConstObject(const C &,ITR (__thiscall C::*
)(void) const,size_t (__thiscall C::* )(void) const)' : could not deduce template argument for 'const T2 &' from
'CharBuf'
e:\Src\C\BlobHolderTest\BlobHolderTest.cpp(29) : see declaration of 'makeConstObject'
(commont-out line 44 to get the second).
It compiles with Comeau
Used Visual studio.net pro version 7.1.3088, dotnet framework 1.1.4322
template <class T> class MyBuffer {
public:
size_t size() const { return length; };
const T* data () const { return buffer; };
T* data () { return buffer; };
private:
T *buffer;
size_t length;
};
template <typename ITR,typename C>
void makeConstObject(const C& container, ITR (C::*get_begin)() const, size_t (C::*get_size)() const) {
}
template <typename ITR,typename C>
void makeObject(C& container, ITR (C::*get_begin)(), size_t (C::*get_size)() const) {
}
void test() {
typedef std::vector<char> CharVec;
typedef CharVec::const_iterator CharVecCITR;
typedef CharVec::iterator CharVecITR;
CharVec v;
makeConstObject<CharVecCITR>(v, &CharVec::begin, &CharVec::size);
makeObject<CharVecITR>(v, &CharVec::begin, &CharVec::size);
std::string hello("Hello");
makeObject(hello, &std::string::begin, &std::string::size); // <---- line 44
typedef MyBuffer<char> CharBuf;
CharBuf cb;
makeObject<char *>(cb, &CharBuf::data, &CharBuf::size);
makeConstObject<const char *>(cb, &CharBuf::data, &CharBuf::size); // <---- æome 49
}
Henrik Ullerichs
Just create a default console project, and paste it at the bottom of the file with _tmain.
e:\Src\C\BlobHolderTest\BlobHolderTest.cpp(44) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 2701)
e:\Src\C\BlobHolderTest\BlobHolderTest.cpp(49) : error C2914: 'makeConstObject' : cannot deduce template argument as
function argument is ambiguous
e:\Src\C\BlobHolderTest\BlobHolderTest.cpp(49) : error C2784: 'void makeConstObject(const C &,ITR (__thiscall C::*
)(void) const,size_t (__thiscall C::* )(void) const)' : could not deduce template argument for 'const T2 &' from
'CharBuf'
e:\Src\C\BlobHolderTest\BlobHolderTest.cpp(29) : see declaration of 'makeConstObject'
(commont-out line 44 to get the second).
It compiles with Comeau
Used Visual studio.net pro version 7.1.3088, dotnet framework 1.1.4322
template <class T> class MyBuffer {
public:
size_t size() const { return length; };
const T* data () const { return buffer; };
T* data () { return buffer; };
private:
T *buffer;
size_t length;
};
template <typename ITR,typename C>
void makeConstObject(const C& container, ITR (C::*get_begin)() const, size_t (C::*get_size)() const) {
}
template <typename ITR,typename C>
void makeObject(C& container, ITR (C::*get_begin)(), size_t (C::*get_size)() const) {
}
void test() {
typedef std::vector<char> CharVec;
typedef CharVec::const_iterator CharVecCITR;
typedef CharVec::iterator CharVecITR;
CharVec v;
makeConstObject<CharVecCITR>(v, &CharVec::begin, &CharVec::size);
makeObject<CharVecITR>(v, &CharVec::begin, &CharVec::size);
std::string hello("Hello");
makeObject(hello, &std::string::begin, &std::string::size); // <---- line 44
typedef MyBuffer<char> CharBuf;
CharBuf cb;
makeObject<char *>(cb, &CharBuf::data, &CharBuf::size);
makeConstObject<const char *>(cb, &CharBuf::data, &CharBuf::size); // <---- æome 49
}
Henrik Ullerichs