Thread View: comp.std.c++
3 messages
3 total messages
Started by Rich Paul
Wed, 13 Mar 1996 23:46
Implementation of class basic_string<class charT, class traits, class Allocator>
Author: Rich Paul
Date: Wed, 13 Mar 1996 23:46
Date: Wed, 13 Mar 1996 23:46
26 lines
1699 bytes
1699 bytes
I am currently implementing, from the working paper, class basic_string. I'm not sure on a couple of things. The first is if the standard says: insert ( const basic_string bs&str ) Does this and that insert ( charT *cp ) insert ( basic_string ( cp ); am I non-complient if I put the real code in the charT* overload and have the other call it? I'm not sure the level of complience that is required ... Also, is there a validation suite that can put this class through it's paces? One more thing ... before calling traits::deallocate, should I explicitly call destructors on the charT's in my array, since it may be a class type, or does the definition of charT as being 'char-like' preclude this? --- [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Re: Implementation of class basic_string<class charT, class traits, class Allocator>
Author: J. Kanze
Date: Thu, 14 Mar 1996 15:23
Date: Thu, 14 Mar 1996 15:23
51 lines
3134 bytes
3134 bytes
In article <3147413B.B10@trcinc.com> Rich Paul <rpaul@trcinc.com>
writes:
|> I am currently implementing, from the working paper, class
|> basic_string. I'm not sure on a couple of things. The first is
|> if the standard says:
|> insert ( const basic_string bs&str )
|> Does this and that
|> insert ( charT *cp )
|> insert ( basic_string ( cp );
|> am I non-complient if I put the real code in the charT* overload
|> and have the other call it? I'm not sure the level of
|> complience that is required ...
At the most, only the externally observable behavior counts. How you
implement the functions is your business. (In some cases, certain
variations in the externally observable behavior are also allowed.)
|> Also, is there a validation suite that can put this class
|> through it's paces?
Is there a compiler which will compile it if it is complete?
|> One more thing ... before calling traits::deallocate, should I
|> explicitly call destructors on the charT's in my array, since it
|> may be a class type, or does the definition of charT as being
|> 'char-like' preclude this?
Good question. In my implementation, I suppose that charT must have a
trivial constructor and destructor, but that is largely because of
laziness on my part; I know of nothing in the standard to support this.
Note that the destructors are not the only problem: you also need the
constructors. More important, when inserting into the stream (and thus
shifting data up), you have to be careful to use the constructor on raw
memory, but assignment on memory that has already been constructed.
Typically, this will mean that you will have to use uninitialized_copy
for part of the shift, and copy_backward for the other.
--
James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils, itudes et rialisations en logiciel orienti objet --
-- A la recherche d'une activiti dans une region francophone
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Re: class basic_string<>
Author: Nathan Myers, http://www.cantrip...
Date: Wed, 20 Mar 1996 16:06
Date: Wed, 20 Mar 1996 16:06
30 lines
2077 bytes
2077 bytes
Rich Paul <rpaul@trcinc.com> wrote: > I am currently implementing, from the working paper, class > basic_string. ... > before calling traits::deallocate, should I > explicitly call destructors on the charT's in my array, since it > may be a class type, or does the definition of charT as being > 'char-like' preclude this? (I assume Paul means Allocator::deallocate.) The requirements on a character type used as an element of a string certainly should be documented, at least as well as are other template parameters in the Draft. As I recall, this was an open issue for the Strings chapter, but the expectation was that characters would be assumed to to have (at most) ignorable constructors and destructors. I have some good news and bad news for Paul ... The bad news is that the traits and allocator interfaces were both changed at the March '96 meeting. The good news is that both are considerably simpler than before. Nathan Myers ncm@cantrip.org http://www.cantrip.org/ [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads