|
-
Jun 6th, 2002, 04:13 PM
#1
String class
I'm working on an extended string class (derived from STL string). What features do you think it should support?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 6th, 2002, 04:34 PM
#2
Monday Morning Lunatic
I don't think you can derive from it (no virtual destructor).
You'd have to implement it as an adapter.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 6th, 2002, 04:51 PM
#3
hmmmm... true, that's what I don't like about the standard library...
What's an adapter?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 6th, 2002, 05:51 PM
#4
Monday Morning Lunatic
It's like that for efficiency reasons (similar to a final Java class), and you wouldn't normally want to derive from the standard containers.
An adapter extends or alters the functionality by compositing an object inside another. Take a look at the source to stack<>, I think that internally uses deque<> to handle the allocation.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 7th, 2002, 02:41 AM
#5
I see.
But since my own destructor does nothing (~WString(){}), does it matter?
WString& destructed -> ~WString() called -> ~tstring called
tstring& destructed -> ~tstring called
Since ~WString does nothing, do I loose anything? Or does the destructor do some secret things I don't know about?
Oh, tstring is defined like this:
#ifdef UNICODE
typedef wchar_t tchar_t;
#else
typedef char tchar_t;
#endif
typedef basic_string<tchar_t> tstring;
I think final Java classes exist mainly for security reasons - so that no one can derive a class and manipulate behaviour.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 7th, 2002, 09:52 AM
#6
Monday Morning Lunatic
Whether a particular implementation does anything "secret" in its destructor is up to the implementer, and you can't rely on it.
I don't know completely what the standard says about the string class, but I definitely know you can't derive from the standard containers.
What sort of functionality were you thinking of adding?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 7th, 2002, 10:45 AM
#7
Functions that do nice things. Search, Strip, Trim, all those things. Maybe RegExp capability.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 7th, 2002, 10:57 AM
#8
Monday Morning Lunatic
Well, it's already got find, but trim is a good one to have.
For regexps, see those boost classes www.boost.org
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|