Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-09-26 11:39:59


--- David Abrahams <dave_at_[hidden]> wrote:

> > [...]
> > - If the constructor of an object A references
> > another object B and the translation units that contain
> > object B are referenced by the program,
> > then the program references all translation
> > units with the static declrations of A.
>
> That sounds like it creates undesirable dependencies. For example,
>
>
> // tu1.cpp
> #include <iostream>
> int main()
> {
> std::cout << "hello, world" << std::endl;
> }
>
> // tu2.cpp
> #include <iostream>
> class Foo
> {
> // huge class declaration
> };
>
> Foo::Foo()
> {
> std::cout << "Foo created" << std::endl;
> }

Sorry, I don't see static declrations in this example
so the suggested rule doesn't apply here.

The rule would work in the following case.

//tu1
class A
{
 static void f();
};

void A::f() { ... }

//tu2
main()
{
   A a;
}

//tu3
class B
{
   B() { A::f(); }
}

B b;

The rule will ensure that the program references tu3 and 'b' will be instantiated.
It is true because the program explicitly references tu1 while tu1 is referenced
in a static declration in tu3.

If we overwrite tu2 as following (no static declrations).
//tu3
class B
{
   B() { A::f(); }
}
int b;

tu3 is not referenced by the program anymore because it doesn't have
a static declrations that use TU's that are already referenced
by the program.

Sure, it is a draft idea I don't know all potential implications of it.

Eugene

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk