Re: Incomplete type as template argument
From: John Carson (donaldquixote_at_datafast.net.au)
Date: 02/25/04
- Next message: Johan: "signalhandler calss"
- Previous message: cob: "structure vs variable"
- In reply to: Victor Bazarov: "Re: Incomplete type as template argument"
- Next in thread: Sharad Kala: "Re: Incomplete type as template argument"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 25 Feb 2004 18:21:08 +1100
"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:g5W_b.54098$Xp.257962@attbi_s54
> "Andrew Ward" <anwar@ihug.co.nz> wrote...
>> Hi All,
>>
>> Considering the following code:
>>
>> struct A;
>>
>> struct B
>> {
>> std::list<A> l;
>
> Neither 'std' nor 'list' is defined.
>
>> };
>>
>> void foo()
>> {
>> B b;
>> };
>>
>> struct A
>> {
>> int x;
>> };
>>
>> int main()
>> {
>> foo();
>> A a;
>> a.x = 22;
>> B b;
>> b.l.push_back(a);
>> cout << "A's value = " << b.l.begin()->x << endl;
>> }
>>
>> I do not understand why the compiler does not complain when
>> encountered with std::list<A> when A has not been fully defined.
>
> I do not understand either. Comeau C++ does complain.
>
>> Could someone please explain to me when the compiler actually does
>> the template expansion, and is this method of using incomplete types
>> as template arguments safe for all compliant compilers?
>
> You should probably ask whoever made your compiler. They must hold
> the secret of how to use an incomplete type as a template argument...
>
> Victor
I don't claim to understand all the subtleties of this matter but... section
14.3.1 p2 of the 2003 standard says:
"[Note: a template type argument may be an incomplete type (3.9). ]"
-- John Carson 1. To reply to email address, remove donald 2. Don't reply to email address (post here instead)
- Next message: Johan: "signalhandler calss"
- Previous message: cob: "structure vs variable"
- In reply to: Victor Bazarov: "Re: Incomplete type as template argument"
- Next in thread: Sharad Kala: "Re: Incomplete type as template argument"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|