Internal compiler error using has_member idiom for templated members
From: Ciprian Ciubotariu (cipi_at_home.ro)
Date: 09/30/04
- Next message: Chris Wood: "64-bit & Managed C++ vs. C++/CLI"
- Previous message: Ioannis Vranos: "Re: Size of int"
- Next in thread: David Lowndes: "Re: Internal compiler error using has_member idiom for templated members"
- Reply: David Lowndes: "Re: Internal compiler error using has_member idiom for templated members"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 30 Sep 2004 14:25:01 +0300
Hi.
I'm trying to use the has_member template to select different paths of
compilation based on the existence of a certain member function. I found a
sample on public domain which compiles just fine. My needs imply doing the
same based on the existence of a possible overload to a template member
function. Trying to adapt the member function implementation of has member
lead to an internal compiler error. However, Comeau compiles it without any
problems. Am I doing something wrong? Should I upgrade? Should Microsoft fix
a bug?
Here is a MSVC version of a sample I found on public domain (has_member for
member functions):
#include "stdafx.h"
#include <iostream>
class C {};
template<class T, bool (T::*)(C&)>
class member_bind
{
public:
typedef T type;
};
template<class T1, class T2>
class has_member
{
public:
static const bool value = false;
};
template<class T>
class has_member<T, typename member_bind<T, T::member>::type>
{
public:
static const bool value = true;
};
class A
{
public:
bool member(C&);
};
class B {};
int main(int argc, char* argv[])
{
std::cout << "A has member? " << (has_member<A, A>::value ? "yes" : "no") <<
std::endl;
std::cout << "B has member? " << (has_member<B, B>::value ? "yes" : "no") <<
std::endl;
return 0;
}
Next is my adapted version which causes the internal compiler error (same
as above, adapted for template member functions):
#include "stdafx.h"
#include <iostream>
class C {};
template<class T, class V, bool (T::*)(V&)>
class member_bind
{
public:
typedef T type;
};
template<class T1, class T2, class V>
class has_member
{
public:
static const bool value = false;
};
template<class T, class V>
class has_member<T, typename member_bind<T, V, T::template member<V>
>::type, V>
{
public:
static const bool value = true;
};
class A
{
public:
template<class T>
bool member(T&);
};
class B {};
int main(int argc, char* argv[])
{
std::cout << "A has member? " << (has_member<A, A, C>::value ? "yes" : "no")
<< std::endl; // commenting out this line makes this snippet compile with
MSVC.
std::cout << "B has member? " << (has_member<B, B, C>::value ? "yes" : "no")
<< std::endl;
return 0;
}
The build log:
------ Build started: Project: test, Configuration: Debug Win32 ------
Compiling...
test3.cpp
d:\Temp\test\test3.cpp(39) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 2701)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Build Time 0:00
Build log was saved at "file://d:\Temp\test\Debug\BuildLog.htm"
test - 1 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
CL.EXE copyright notice:
Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
HTML Buildlog attached
begin 666 BuildLog.htm
M/&AT;6P^#0H\:&5A9#X-"CQ-151!($A45% M15%5258](D-O;G1E;G0M5'EP
M92(@8V]N=&5N=#TB=&5X="]H=&UL.R!C:&%R<V5T/5=I;F1O=W,M,3(U,B(^
M#0H\+VAE860^#0H\8F]D>3X-"CQP<F4^#0H\=&%B;&4@=VED=&@],3 P)2!B
M9V-O;&]R/2-#1D-&134^/'1R/B \=&0^(#QF;VYT(&9A8V4]87)I86P@<VEZ
M93TK,SX-"D)U:6QD($QO9PT*/"]F;VYT/CPO=&%B;&4^/'1A8FQE('=I9'1H
M/2H@8V5L;'-P86-I;F<],"!C96QL<&%D9&EN9STP/CQT<CX\=&0@=VED=&@]
M,"!B9V-O;&]R/2-%1$5$1C4^)FYB<W [/"]T9#X\=&0@=VED=&@],"!B9V-O
M;&]R/2-&1D9&1D8^)FYB<W [/"]T9#X\=&0@=VED=&@]*CX\<')E/@T*/&@S
M/BTM+2TM+2T@0G5I;&0@<W1A<G1E9#H@4')O:F5C=#H@=&5S="P@0V]N9FEG
M=7)A=&EO;CH@1&5B=6=\5VEN,S(@+2TM+2TM+0T*/"]H,SX-"CPO<')E/CPO
M=&%B;&4^/'1A8FQE('=I9'1H/3$P,"4@8F=C;VQO<CTC1$9$1D4U/CQ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&9O;G0@9F%C93UA<FEA;"!S:7IE/2LR/@T*/"]F;VYT/CPO
4=&%B;&4^/"]B;V1Y/CPO:'1M;#X`
`
end
- Next message: Chris Wood: "64-bit & Managed C++ vs. C++/CLI"
- Previous message: Ioannis Vranos: "Re: Size of int"
- Next in thread: David Lowndes: "Re: Internal compiler error using has_member idiom for templated members"
- Reply: David Lowndes: "Re: Internal compiler error using has_member idiom for templated members"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|