[Effective-cpp] Item 2: The String Formatters of Manor Farm, Part 1: sprintf

Terje Slettebø tslettebo at broadpark.no
Sun Oct 31 05:13:15 EST 2004


>From: "Lois Goldthwaite" <lois at loisgoldthwaite.com>

> On Friday 29 October 2004 00:36, Paul Grenyer wrote:
> > Are there any C++ functions that do use ...?
> > Or is it only function sinheritted from C?
>
> I believe (without actually taking the trouble to look things up) that it
is
> only the ones inherited from C. Since C++ already has the ability to
overload
> a function name with versions taking different numbers and types of
> arguments, there is less need for a takes-anything workaround.

Furthermore, with templates, you can take any type, while still keeping type
safety:

template<class T>
void f(const T &) { ... }

Now, if we had variadic templates... :)
(http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2003/n1483.pdf) Then we
would be able write functions or function templates taking any number of any
type, and still keep it type-safe and generic.

When it comes to features for C++0x, I think this is the kind of additions
we should focus on, and which was also given in the references in Attila's
post: Supporting library building and generic programming. Thus, apart from
the above, I think rvalue references
(http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1690.html),
enabling "move semantics" and "perfect forwarding" (together with the
variadic proposal), as well as partial specialisation of function templates
(http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2001/n1295.asc) could
help filling in the picture, enabling even better libraries.

This is rather on the side of the topic, but as we had a discussion about
C++0x proposals.

Regards,

Terje




More information about the Effective-cpp mailing list