Re: Where to place a constant?
From: Rolf Magnus (ramagnus_at_t-online.de)
Date: 02/16/04
- Next message: André Pönitz: "Re: Arithmetics"
- Previous message: André Pönitz: "Re: Where to place a constant?"
- In reply to: Lasse Skyum: "Re: Where to place a constant?"
- Next in thread: Lasse Skyum: "Re: Where to place a constant?"
- Reply: Lasse Skyum: "Re: Where to place a constant?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 16 Feb 2004 13:27:29 +0100
"Lasse Skyum" <no spam> wrote:
>> >Suggestions anyone?
>>
>> You'd be much better off using std::string.
>
> Okay... maybe so, but I don't really se why? CBL_String helps me in
> manny different ways and has never been the source of any bugs in my
> programs.
>
> Does std::string have a shared empty string or maybe it uses NULL as
> an empty string?
I'd say that's implementation specific. Anyway, why do you think you
need such a shared ... ehm, nothing? I mean, an empty string has no
data to share. Its size is 0, so there is nothing to read from it, so
why would you need to share that 'nothing' between empty strings? Btw:
Do you actually have that many empty strings in real programs?
> If std::string also allocated an empty string if not initialized, then
> I see no reason what so ever to use it...
>
> BTW, I've also written my own CBL_ArrayList as an equivalent to
> vector... ony differenceis the ability to automatically shrink if a
> flag is set.
If you're happy with your own containers and strings, it's IMHO ok to
use them. Of course, you'll limit code reusability somewhat.
> For some odd reason it also outperformes vector in my
> insert/remove benchmarks, probably just a bunch of settings or
> something.
That again depends on the implementation you use, not only on settings.
> I'm sure all this is also in Boost (or whatever C++ extentions there
> might be) but I've learned so much be writing it my self.
That's of course a very good reason to write your own ones, but it is
not a reason to use them in real code :-)
> Anyway... I just wanted to have an initialized constant :-) Might
> also be relevant for other things!
If you want to be sure that your constant is initialized before other
static objects, you might want to use the singleton pattern.
- Next message: André Pönitz: "Re: Arithmetics"
- Previous message: André Pönitz: "Re: Where to place a constant?"
- In reply to: Lasse Skyum: "Re: Where to place a constant?"
- Next in thread: Lasse Skyum: "Re: Where to place a constant?"
- Reply: Lasse Skyum: "Re: Where to place a constant?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|