This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] char_traits error checking


On Mon, Mar 11, 2002 at 09:35:02PM -0800, Benjamin Kosnik wrote:
> 
> 21.3.1 - basic_string constructors
> basic_string(const charT* s, const Allocator& a = Allocator());
> -9- Requires:  s shall not be a null pointer.

I looked at this as part of PR 5258.  The way the ctors are arranged in
basic_string.tcc doesn't seem to give us any opportunities to do checking on
the arguments:  the string data is built (and dereferenced) in the member
init list, so no "if NULL throw logic_error" is possible unless we break
that out into a ctor body.

(Oooooh, can we use GCC's expression statements extension in member
init lists?  I didn't think of that until just now.)


As for the member functions, if we make "no NULL pointers" a string class
invariant / postcondition, those problems are neatly sidestepped.

Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]