Topic: Favourite C++0x features


Author: tslettebo@hotmail.com (Terje Sletteb?)
Date: Fri, 30 Jul 2004 04:09:41 GMT
Raw View
nagle@animats.com (John Nagle) wrote in message news:<6dpKc.23489$N82.18042@newssvr27.news.prodigy.com>...
> Terje Sletteb? wrote:
>
> > Hi.
> >
> > This post is inspired by Scott Meyers's "Likely C++0x features"
> > thread.
> >
> > There's been several, long threads about possible C++0x features. It
> > can be hard for someone coming later to get an overview of the
> > proposals from a huge thread, and their relative popularity. This
> > thread is aimed at addressing that.
>
>     Other than template-related features, what changes are being
> proposed?  Any improvements in soundness or reliability
> or robustness or safety?

Improving support for generic programming makes it possible to write
easy-to-use, powerful libraries. An example is std::string and the
STL, which have eliminated much of the problems involved in manually
managing memory and tracking ownership.

Any particular issues or improvements you have in mind?

Naturally, C++ could have been a lot stricter in its type checking
(such as what implicit conversions are allowed between the built-in
types), but that would make it rather a lot less compatible with C, as
well as possibly breaking a lot of existing code.

Regards,

Terje

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: tslettebo@hotmail.com (Terje Sletteb?)
Date: Fri, 16 Jul 2004 17:08:47 +0000 (UTC)
Raw View
Hi.

This post is inspired by Scott Meyers's "Likely C++0x features"
thread.

There's been several, long threads about possible C++0x features. It
can be hard for someone coming later to get an overview of the
proposals from a huge thread, and their relative popularity. This
thread is aimed at addressing that.

What I'm interested in here are your favourite new features for C++0x
(the new C++ standard).

To "count", each feature should be presented with at least one use
case, or reference to such, and, if it exists, a reference to an
existing paper describing the feature, unless this has been given in
another posting. This should be given even for "obvious" features like
"typeof" or "typedef templates".

This is to ensure that there's real use for the feature.

This may give the people working with standardisation a feel for which
features are most popular/in demand, among developers.

To kick it off, here's my list. There may be many use cases, but only
a few is given. More is usually in the proposal paper:

- typeof/decltype/auto (whatever it's called)
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1607.pdf)

  Use cases: There are many, but here's one:
  - Implementation of result_of
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1437.html),
for return type deduction. This is useful for forwarding functions and
adapters.

- Typedef templates/aliases
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1449.pdf)

  Use cases:
  - Policy-based classes, such as smart pointers (avoiding "::type"
after, and enables deducibility)

- Partial specialisation of function templates
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2001/n1295.asc)

  Use cases:
  - It's possible to specialise, but not overload, names in the
standard library. This means that with this feature, it would be
possible to specialise e.g. std::swap, for a user-defined class
template.

- Move semantics/rvalue references
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1377.htm,
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm)

  Use cases:
  - Solving the forwarding problem, and efficient copy/move.

- Typesafe variable-length function and template argument lists
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1483.pdf)

  Use cases:
  - Enabling creating forwarding functions without an arbitrary limit
to the number of arguments and a ton of default parameters.
  - Tuple/typelists/etc. without the same problem as the forwarding
functions.

The above proposals constitute some powerful generic building blocks
(in addition to what we already have). Note also that many of these
work well together, and therefore constitutes a whole that is greater
than the sum of the parts.

They also "fill in" parts of C++, making it more regular, and
flexible:

- Partial specialisation of function templates completes the
specialisation (you currently can partially specialise class
templates, but not function templates)

- Variable-length function and template argument lists provide the
possibility for generic forwarding and adaption functions, making it
easier to use functional programming in C++, as well as other features
like tuples and typelists.

- Rvalue references/move semantics add to the last point, making it
work in all cases, and the same with typeof. These provide
"plumbing"/infrastructure for other proposals.

- Typedef templates/aliases provides better support for policy-based
design, and other uses.

Following the above list, I have some more "minor" features - features
that might have less broad applicability or impact on the language, or
possibly less work developing:

- Selective compiler-generated default functions
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1582.pdf)

  Use cases:
  - Less surprises, being able to be more explicit about what the
compiler generates.
  - Avoiding the private-and-not-implemented hack for preventing
copying.

- Constructor inheritance
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1582.pdf)

  Use cases:
  - Enabling strong typedefs: struct new_type : old_type {};

- Support for delegation
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1363.htm)

  Use cases:
  - Being able to use containment without having to manually write
forwarding functions.
  - If the proposal is changed to include delegation to built-in
types, this might be used for strong typedefs for built-in types (see
http://groups.google.com/groups?selm=b0491891.0407110535.67dcf23c%40posting.google.com).

Some nice-to-have's:

- Delegating constructors
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1581.pdf)

  Use cases:
  - Being able to remove boilerplate redundancy for constructors.

- Strongly typed enums
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1579.pdf)

  Use cases:
  - Avoiding implicit conversion to int, enabling scoped enums, etc.,
tightening up the type system.

Some in the interesting, potentially useful, more experience might be
needed-category:

- Uniform calling syntax
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1579.pdf)

  Use cases: Being able to call member and non-member functions in the
same way. This may make it easier to extend functionality in a uniform
way, as well as may be useful in generic code.

- Multimethods (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1463.html)

  Use cases:
  - Some cases are handling of collision between objects, computing
intersections between shapes, etc. More real-life examples could be
useful.

- Allowing overloading operator. (dot)
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1598.html)

  Use cases:
  - Enabling proxies.

- Explicit operator conversion functions
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1598.html)

  Use cases:
  - To match explicit constructors, no implicit conversion.

In a category of its own:

- Reflection.

Points to consider here, is whether or not reflection information
should be available at compile-time, or run-time, and how it may be
accessed.

A more long-term feature, with potentially large impact:

- Concepts (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1510.pdf)

  Use cases:
  - Nothing short of revolutionising generic programming in C++.

And, oh yeah:

- Allowing ">>" in templates
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1649.html)

  Use cases:
  - It avoids having to use whitespace between ">"s, thus working the
same way as parentheses.

The above categories (major, minor, nice to have, etc.) are just
ideas, and feedback is welcome.

In the above list, like Scott Meyers's list, I haven't included what
may be even more minor things (that's of course open to debate), yet
useful (allow local classes as template parameters, null pointer
constant, static assertions, override)

There are several other interesting proposals, but these are some of
those I found most interesting and useful.

These are core language changes. If there's interest, another thread
could be used for library changes.

Anyone else's favourites, not mentioned here, or which should get more
priority?

This might give some inspiration:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1598.html

Regards,

Terje

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: nagle@animats.com (John Nagle)
Date: Mon, 19 Jul 2004 06:04:47 +0000 (UTC)
Raw View
Terje Sletteb? wrote:

> Hi.
>
> This post is inspired by Scott Meyers's "Likely C++0x features"
> thread.
>
> There's been several, long threads about possible C++0x features. It
> can be hard for someone coming later to get an overview of the
> proposals from a huge thread, and their relative popularity. This
> thread is aimed at addressing that.

    Other than template-related features, what changes are being
proposed?  Any improvements in soundness or reliability
or robustness or safety?

    John Nagle
    Animats

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: tslettebo@hotmail.com (Terje Sletteb?)
Date: Fri, 16 Jul 2004 14:10:59 +0000 (UTC)
Raw View
Hi.

This post is inspired by Scott Meyers's "Likely C++0x features"
thread.

There's been several, long threads about possible C++0x features. It
can be hard for someone coming later to get an overview of the
proposals from a huge thread, and their relative popularity. This
thread is aimed at addressing that.

What I'm interested in here are your favourite new features for C++0x
(the new C++ standard).

To "count", each feature should be presented with at least one use
case, or reference to such, and, if it exists, a reference to an
existing paper describing the feature, unless this has been given in
another posting. This should be given even for "obvious" features like
"typeof" or "typedef templates".

This is to ensure that there's real use for the feature.

This may give the people working with standardisation a feel for which
features are most popular/in demand, among developers.

To kick it off, here's my list. There may be many use cases, but only
a few is given. More is usually in the proposal paper:

- typeof/decltype/auto (whatever it's called)
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1607.pdf)

  Use cases: There are many, but here's one:
  - Implementation of result_of
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1437.html),
for return type deduction. This is useful for forwarding functions and
adapters.

- Typedef templates/aliases
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1449.pdf)

  Use cases:
  - Policy-based classes, such as smart pointers (avoiding "::type"
after, and enables deducibility)

- Partial specialisation of function templates
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2001/n1295.asc)

  Use cases:
  - It's possible to specialise, but not overload, names in the
standard library. This means that with this feature, it would be
possible to specialise e.g. std::swap, for a user-defined class
template.

- Move semantics/rvalue references
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1377.htm,
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1385.htm)

  Use cases:
  - Solving the forwarding problem, and efficient copy/move.

- Typesafe variable-length function and template argument lists
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1483.pdf)

  Use cases:
  - Enabling creating forwarding functions without an arbitrary limit
to the number of arguments and a ton of default parameters.
  - Tuple/typelists/etc. without the same problem as the forwarding
functions.

The above proposals constitute some powerful generic building blocks
(in addition to what we already have). Note also that many of these
work well together, and therefore constitutes a whole that is greater
than the sum of the parts.

They also "fill in" parts of C++, making it more regular, and
flexible:

- Partial specialisation of function templates completes the
specialisation (you currently can partially specialise class
templates, but not function templates)

- Variable-length function and template argument lists provide the
possibility for generic forwarding and adaption functions, making it
easier to use functional programming in C++, as well as other features
like tuples and typelists.

- Rvalue references/move semantics add to the last point, making it
work in all cases, and the same with typeof. These provide
"plumbing"/infrastructure for other proposals.

- Typedef templates/aliases provides better support for policy-based
design, and other uses.

Following the above list, I have some more "minor" features - features
that might have less broad applicability or impact on the language, or
possibly less work developing:

- Selective compiler-generated default functions
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1582.pdf)

  Use cases:
  - Less surprises, being able to be more explicit about what the
compiler generates.
  - Avoiding the private-and-not-implemented hack for preventing
copying.

- Constructor inheritance
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1582.pdf)

  Use cases:
  - Enabling strong typedefs: struct new_type : old_type {};

- Support for delegation
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1363.htm)

  Use cases:
  - Being able to use containment without having to manually write
forwarding functions.
  - If the proposal is changed to include delegation to built-in
types, this might be used for strong typedefs for built-in types (see
http://groups.google.com/groups?selm=b0491891.0407110535.67dcf23c%40posting.google.com).

Some nice-to-have's:

- Delegating constructors
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1581.pdf)

  Use cases:
  - Being able to remove boilerplate redundancy for constructors.

- Strongly typed enums
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1579.pdf)

  Use cases:
  - Avoiding implicit conversion to int, enabling scoped enums, etc.,
tightening up the type system.

Some in the interesting, potentially useful, more experience might be
needed-category:

- Uniform calling syntax
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1579.pdf)

  Use cases: Being able to call member and non-member functions in the
same way. This may make it easier to extend functionality in a uniform
way, as well as may be useful in generic code.

- Multimethods (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1463.html)

  Use cases:
  - Some cases are handling of collision between objects, computing
intersections between shapes, etc. More real-life examples could be
useful.

- Allowing overloading operator. (dot)
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1598.html)

  Use cases:
  - Enabling proxies.

- Explicit operator conversion functions
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1598.html)

  Use cases:
  - To match explicit constructors, no implicit conversion.

In a category of its own:

- Reflection.

Points to consider here, is whether or not reflection information
should be available at compile-time, or run-time, and how it may be
accessed.

A more long-term feature, with potentially large impact:

- Concepts (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1510.pdf)

  Use cases:
  - Nothing short of revolutionising generic programming in C++.

And, oh yeah:

- Allowing ">>" in templates
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1649.html)

  Use cases:
  - It avoids having to use whitespace between ">"s, thus working the
same way as parentheses.

The above categories (major, minor, nice to have, etc.) are just
ideas, and feedback is welcome.

In the above list, like Scott Meyers's list, I haven't included what
may be even more minor things (that's of course open to debate), yet
useful (allow local classes as template parameters, null pointer
constant, static assertions, override)

There are several other interesting proposals, but these are some of
those I found most interesting and useful.

These are core language changes. If there's interest, another thread
could be used for library changes.

Anyone else's favourites, not mentioned here, or which should get more
priority?

This might give some inspiration:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1598.html

Regards,

Terje

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]