|
Boost Users : |
Subject: Re: [Boost-users] [random] Singleton engine
From: Kevin Martin (kev82_at_[hidden])
Date: 2009-08-17 06:10:33
On 17 Aug 2009, at 10:44, Diederick C. Niehorster wrote:
> It doesn't add only two symbols though, it adds:
> generator_
This should not be exported, in fact exporting this defeats the
purpose of having generator and setGenerator. It should be in it's own
compilation unit with static linkage and not in a header file visible
to anything else.
> grng_setGenerator()
This is one symbol
> grng_generator()
This is another symbol
> grng_randomVariable()
This is a template function and is recompiled in every compilation
unit where it is used. I have never checked, but I always assumed that
the compiler would inline it, so it shouldn't even be a function,
never mind an exported symbol. However, you are right that it does add
an extra name you can't use, I was thinking in terms of exported
symbols.
> or do you put those in their own namespace?
I've still not really got to grips with when to put things in
namespaces and when not to. At the moment I only tend to use a
namespace if I have a large collection of classes constituting a
module. The grng_ prefix is kind of like a namespace to remind me what
the functions are for because a global function setGenerator and
generator are not very specific and likely to introduce collisions. I
don't think it would cause any harm to put them in their own namespace
though.
> Thanks again, I've been enlightened.
Glad I could help
Thanks,
Kevin Martin
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net