Re: Two-stage name lookup problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Your problem is not with templates.
>
> Here's your problem in a nutshell...
>
> struct A
> {
>     int x;
>
>     struct B
>     {
>         A a;
>     };
> };
>
>
> You cannot use A within B, because at that point A is incomplete.
>
> You can pull B out of A.  If you want B to be in the A namespace, change
> 'struct A' to 'namespace A', and make 'struct A_impl', fully declared, and
> then use that within 'struct B'.

But what about function f(), the member of struct A? I want to declare
variable with type B in the body of the function:

struct A {
    ...
    void f()
    {
        B b;
        ...
    }
};

I am aware that kind of code may be ill formed, but when using
templates, there should be something like deferred instantiation.
Struct B is a template and also function A::f() is a template. Struct
B is needed only when function A::f() is used. Struct B should be able
to construct member of type A and Struct B do not use function A::f().
I want all functions be inline. Any solutions?


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux