Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > a hard problem about template specification

Reply
Thread Tools

a hard problem about template specification

 
 
Eric Pruneau
Guest
Posts: n/a
 
      06-20-2008

"Eric Pruneau" <(E-Mail Removed)> a écrit dans le message de news:
bKR6k.6957$(E-Mail Removed)...
>
> "Eric Pruneau" <(E-Mail Removed)> a écrit dans le message de news:
> 9DR6k.8917$(E-Mail Removed)...
>>
>> "Marcel Müller" <(E-Mail Removed)> a écrit dans le message de
>> news: 485b9dba$0$6601$(E-Mail Removed)-online.net...
>>> Hi,
>>>
>>> http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
>>>> I paste it again.
>>>>
>>>> (1)
>>>> template<typename L, typename R, bool b1=false, bool b2=false>
>>>> struct A
>>>> {
>>>> A() {cout<<"1\n";}
>>>>
>>>> };
>>>>
>>>> (2)
>>>> template <typename L, typename R>
>>>> struct A<L, R, true, true>
>>>> {
>>>> A(){cout<<"2\n";}
>>>> int operator()(int i);
>>>>
>>>> };
>>>>
>>>> (3)
>>>> template< >
>>>> A<int,int>:perator()(int i)
>>>> {
>>>> cout<< i<<endl;
>>>>
>>>> }
>>>>
>>>>
>>>> int main()
>>>> {
>>>> return (new A<int,int,true,true>)->operator()(5);
>>>>
>>>>
>>>> }
>>>
>>> Your code still does not compile, since A<int,int,false,false> does not
>>> have operator()(int) defined. Furthermore this operator has no return
>>> value. Both are errors.

>>
>> this example compile and run fine with the intel compiler

>
> Wait, I wrote
> template< > A<int,in,true,truet>:perator()(int i) { ...}
>
> for (3)
>
> I agree that like if you try to compile the example like it is, it will
> not compile.


I meant will not link since operator() of (2) is not defined


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
template specification oddness Matthias Buelow C++ 4 02-23-2008 09:09 AM
Re: template specification oddness Victor Bazarov C++ 3 02-21-2008 07:35 PM
partial ordering of template functions & parameter specification Marek Vondrak C++ 9 05-15-2006 02:45 PM
template specification Marc Schellens C++ 4 10-04-2003 01:56 PM
Re: A Newbie Question about template template template Chris Theis C++ 2 07-24-2003 09:42 AM



Advertisments