Date: 1999-12-10 16:59:49
So the letter of the law makes it illegal, but was this really the
intention? Seems to me this causes nasty problems for generic
libraries. Since std::abs() is not all-applicable, it forces
the *user* to do "using std::abs;" etc, for every operation
of this nature that is used in the algorithm. What if the algorithm
is large and there are lots of these? Nasty barrier to reuse...
Darin Adler writes:
> > | There is a std::abs() template function, for the complex class.
> > | Therefore it is both legal to put the rational abs() function in the
> > ^^^^^
> > | std namespace and highly recommended since a generic algorithm should
> > | be able to use std::abs() on any numeric type including user defined
> > | types.
> > 'legal' on which basis? If it is by the Standard, the chapter and verse.
> 18.104.22.168/1: "It is undefined for a C++ program to add declarations or
> definitions to namespace std or namespaces within namespace std unless
> otherwise specified. A program may add template specializations for any
> standard library template to namespace std. Such a specialization (complete
> or partial) of a standard library template results in undefined behavior
> unless the declaration depends on a user-defined name of external linkage
> and unless the specialization meets the standard library requirements for
> the original template."
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk