Topic: Implications of Returns-clauses


Author: David Vandevoorde <daveed@cup.hp.com>
Date: 1998/06/26
Raw View
To: C++ libraries mailing list
Message c++std-lib-6530

Hello,

Chapter seventeen explains that "Returns"-clauses describe
values returned by standard functions. Are side-effects
(such as throwing of exceptions) of an expression specified
in a Returns-clause also mandated? Or is it strictly
specifying the return-value only.

Example:

21.3.6.8  basic_string::compare [lib.string::compare]
[... last signature]
  int compare(size_type pos, size_type n1,
              charT *s, size_type n2 = npos) const;

  Returns:
  basic_string<charT,traits,Allocator>(*this,pos,n1).compare(
               basic_string<charT,traits,Allocator>(s,n2))

The constructor in this "Returns" expression may throw.
Should this also be a (side-) effect of this signature?
Can an implementation elide the temporary?

Or should "Effects" and "Throws" clauses be copied/updated
in such cases.

 Daveed
---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]