473,322 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Bug in VS 2003.Net - Template parameter deduction

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
Nov 17 '05 #1
1 1091
Henrik,

The problem reproduces with the Whidbey alpha compiler, so I'll try to
pass on your report to MS.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris Johnson | last post by:
Greetings all: I come across an interesting question (to me anyway) and I do not know the answer. Code/Questions follow: #include <iostream> #if 0 // uncommenting *should* make call...
3
by: BigMan | last post by:
Here is a piece of code: #include <memory> using namespace std; template< typename SomeType > void f(auto_ptr_ref< SomeType >) { }
4
by: Mat DeLong | last post by:
I have never been stuck on programming something before to the point I give up... this is a first. I am programming what should be something very easy in C++... using Templates. Here is the code,...
14
by: Bart Samwel | last post by:
Hi everybody, I would really like some help explaining this apparent discrepancy, because I really don't get it. Here is the snippet: void foo(int&); void foo(int const&); ...
4
by: Neelesh | last post by:
Hi all, I had some confusion about deduction of non-type template parameters for function templates : template <class T, int i> void foo (T, int p = i) ; void bar() { foo<int, 10>(40,40);...
2
by: coolpint | last post by:
Can anyone kindly provide an explanation as to why the compiler does not "see" the function template in the contrieved code below? I think the argument deduction fails but can't figure out...
0
by: Fei Liu | last post by:
Hello, We all know that a template function can automatically deduce its parameter type and instantiate, e.g. template <tpyename T> void func(T a); func(0.f); This will cause func<floatto...
3
by: Fei Liu | last post by:
Hello, We all know that a template function can automatically deduce its parameter type and instantiate, e.g. template <tpyename T> void func(T a); func(0.f); This will cause func<floatto...
4
by: KD | last post by:
I have a template function and I'm looking for a way to force the caller to specify the template parameters. In other words, I would like to turn off template parameter deduction. For example, ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.