tags:

views:

1455

answers:

23

I know that C++0x is not out the door yet, but what would you like to see in C++1y?


Update: C++0x to be called C++1x :o(

+3  A: 

Most probably C++0x will be C++1x, because it won't be finished in 2009.

And most importantly, I would like to lay my hands on finished, production ready C++(0|1)x :)

zeroDivisible
I can't believe it has taken nearly 10 years to produce an unfinished standard. I remember getting excited about the proposals for the new language features back in 2002!
Steve Guidi
Let x be a hexadecimal number ;) C++0A seems probable
carlpett
Steve: Then look at the timeframe for HTML5, and suddenly C++0x seems to have a very sane time frame.
Michael Stum
@carlpett: it's a roman numeral. X is 10.
Thomas
The reason why C++0x isn't here yet is because of concepts. They are complicated, and getting them done right is hard - especially as there are no up-to-date implementations (even research ones) on which to test the design (ConceptGCC is already outdated).A good explanation of where things are at the moment is this paper: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2893.pdf
Pavel Minaev
Concepts were dropped.
Edouard A.
I believe one reason that it's taken so long is simply that they wanted to give the C++ community time to catch up. It's not until a couple of years ago that reasonably standard-compliant compilers really became commonplace. And a lot of C++ programmers are still struggling to catch up with STL, Boost and generic programming. I think the delay was necessary. But future revisions should definitely come out more often (and I believe the committee has mentioned aiming for a 5-year cycle in the future).
jalf
+44  A: 

I'd like to see modules. I'm getting more sick of #includes and slow compilation every day.

avakar
agreed. Any news on this? Are they still looking to do that in a TR?
jalf
this is the number 1 thing they should have stuck with, they ignored the excellent proposal for modules.
Hassan Syed
+23  A: 

A standard ABI (Binary interface) would be great.

milan1612
The better way to do that is a TR (Technical Report). See for instance TR1 on library extensions.
MSalters
This really fits with @avakar answer: modules that are not compiler dependent
David Rodríguez - dribeas
I'm sick of writing objects in every language under the sun, and having zero reusability without having to resort to heavyweight object-sharing like CORBA or COM.
Chris Kaminski
ABI's are pretty hard to standardise since it depends on the OS and CPU architecture.
Hassan Syed
Agree with @Hassan. C++ avoids standardizing anything that's even slightly platform dependent.
Billy ONeal
Stack frame formats can't be standardized, and allowing stack hacking would be bad for several reasons. On the other hand, standardized name mangling would have some advantages, but problems (possibly reduced efficiency) would be result from retrofitting to existing ABI's. A library unmangler would be nicer, but ultimately only useful for debugging, which I suppose is why there isn't one already. (Repeat this debate for every section of every ABI.)
Potatoswatter
A: 

Would be nice:

  • virtual constructors and virtual copy constructors. So factories and
    cloning can be done more naturally
  • multiple dispatch functions
stefaanv
How would virtual constructors work? I mean, don't you need to know the type of object you want? Copy, I could see, since you already have an object of some type... but the base case? I don't get it.
Caleb Huitt - cjhuitt
cjhuitt, virtual constructor is a name for an idiom: http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.8
avakar
@avakar: OK, so a virtual constructor is to get a default-constructed object of the same type as an existing object. I still don't see how that would be useful in factories.
Caleb Huitt - cjhuitt
@cjhuitt: The point of virtual constructors is so that if a factory gives you a Foo* which may point to an instance of some class derived from Foo, you have a way to perform a complete, non-sliced duplication of the pointed-to object, or to create a new object of the same type, without needing to know what the underlying dynamic type of the object actually is. Doing this in C++ currently requires either a lot of code duplication, or a pile of template-based hackery.
Tyler McHenry
A: 

inline keyword deprecated. Its almost as useless as the old "register" keyword.

(that is to say its a very vague hint at best, not that I'm against inlining).

Justicle
`inline` keyword has little to do with code inlining (at least since 1998). `inline` marks a function so that multiple (but equivalent) definitions of the same function are not considered an error by the linker. The keyword is very much necessary and cannot be deprecated.
avakar
Max Lybbert
Max, I couldn't agree more. I'd say that `inline` is much worse than cryptic syntax, because with the latter, we're able to recognize that we don't understand it and simply learn. The former, however, leaves us with a false belief that we understand what it means and eventually results in a lot of confusion.
avakar
+6  A: 

I don't know if anything similar has been submitted, but I'd very much like an equivalent of typedef that defines a new type so that you would be forced to use a static_cast<> to convert from one type to another.

For example you could define a class like this :

class Person
{
public:
    // the *typedef new* is just an idea for the syntax that could be used
    typedef new std::string name_t; 
    Person(const name_t& name);

    const name_t& getName() const;

    void setName(const name_t& name);
};

And using it like this wouldn't compile

void func()
{
    std::string name("Etienne");
    Person person(name); //<-- this wouldn't compile

}

But this would

void func()
{
    Person::name_t name("Etienne");
    Person person(name);
}

This way you could be sure that the users of your class really use the typedef you intended to use.

Etienne PIERRE
`typedef new std::string name_t;`? Do you mean `typedef std::string name_t;`?
GMan
No it's just an idea of the syntax that could be used and which would mean : define a new type name_t that is the same as std::string but is a new type and not just an name alias.
Etienne PIERRE
This "strong typedef" is supported by D, IIRC. I agree it'd be nice.
tragomaskhalos
explicit is a C++ keyword, in some situations preventing implicit type conversions. Is that what you mean?
LiraNuna
Not really, explicit qualifies a constructor to avoid calling it implicitly to make a conversion, but you still have to write a new type. But if you want to create one that is identical to another, you use typedef which only defines a new name, not a new type.
Etienne PIERRE
So you want 2 different types that are different from the compilers point of view for type conversion and matching but have the same implementation. I like this idea. And it wouldn't be hard to implement.
Matt Price
Huge massive complex library 'A' has defined it's own 3D point type and H.M.L. 'B' has a different type so you spend all your time coping MBytess from one set of 3 floats to another set of 3 floats.
Martin Beckett
There has been a lot of committee push towards this. This is the feature on this page that is almost guaranteed to get in. Modules are likely, but may not be, as with polymorphic lambdas, but opaque typedefs were narrowly missed by C++0x - I'd expect to see them in the future!
coppro
Boost strong typedef: http://www.boost.org/doc/libs/1_39_0/boost/strong_typedef.hpp.
Éric Malenfant
Great for keeping different "flavours" of strings (e.g. raw and URL-escaped) separate. With a bit of discipline in declaring function parameter and return types, you can use the compiler's type system to eliminate this class of security bugs. Joel Spolsky has a nice article on this: http://www.joelonsoftware.com/articles/Wrong.html
j_random_hacker
+20  A: 

I'd really like to see polymorphic lambdas. The lambdas that we get in the next Standard are monomorph only

auto intPrinter = [](int x) { std::cout << x; };
// can only print int!

Polymorph lambdas would allow for more readable code and for less duplication. No need anymore for repeated writing of type-names anymore:

for_each(a.begin(), a.end(), [](x) { x++; });

As you see, we wouldn't need to spell out the type of the parameter. An alternative syntax would be using templates

for_each(a.begin(), a.end(), template<typename T> [](T &x) { x++; });
Johannes Schaub - litb
Nice proposition!
Dario
I wouldn't call it polymorphic lambdas. I'd call it templated lambdas. Technically both are correct, but polymorphic brings a virtual tables to mind.
caspin
It's been discussed but discarded for 0x. I'm unsure about the rejection reason but I submit it's due to the complexity of implementing a fully generic lambda.
Edouard A.
I read the lambda paper. They rejected them because that feature is provided by libs like boost.lambda in parts, and because they found it not really worth. Something along that way. @Caspin, that's what they are "officially" called. I didn't invent that term, but i don't like it either :)
Johannes Schaub - litb
+1 - yeah - i couldn't believe they didn't add them - not only that, i was quite surprised that they decided not to add local templates in C++0x -
Faisal Vali
The term "polymorphic" has a long history outside OOP languages though, and using it to describe lambdas in this way is perfectly in tune with the terminology used in functional languages. Also yes, I'd love to see it added. Perhaps as we gain some real-world experience with the current lambda implementation, they'll be willing to take that extra step in the next revision.
jalf
I thought `for_each(a.begin(), a.end(), [](auto x) { x++; });` would work?
+1 but I would call the feature "local templates"
Potatoswatter
+1  A: 

There are no things I'd like added to already huge and complex language. There are plenty I'd like to see removed or redesigned :(

porneL
It'd be nice if they could deprecate arcane and troublesome features. The first time around compilers could emit a warning. An iteration of C++ after a feature has been flagged deprecated, it could be removed altogether.
luke
@luke - isn't going to happen. Most large C++ developers have a huge legacy code base. The last thing they will do is spend hundreds of thousands of dollars upgrading it so they can use the latest compiler. More likely they will just wait for a vendor to provide the new features with decent legacy support.
Tom Leys
+14  A: 

Another feature i would like to see are string template arguments. This would for example allow for static (compile-time) checking and compilation of regular expressions, file-paths and others.

An alternative would be user defined literal operator templates that accept string literals. That is, the following would be nice to have

template<char... C>
constexpr regex operator "" _regex() 
{ return compile<C...>::value(); }

regex numbers = "[0-9]+"_regex;

And it would check and compile the regex at compile time. This is currently only allowed for integer or floating point literals for the next Standard.

Johannes Schaub - litb
Sounds like a pretty hairy feature to implement. You'd need some sort of pseudo-linker in the compiler itself I guess. What advantage do you see with compile time regex?
Edouard A.
Speed and fail-fast, of course. This already works for numeric literals. It wasn't accepted for string literals because of problems with concatenating strings, from what i heard, like `"A" "B"_regex`.
Johannes Schaub - litb
+1 - yes - these would be very kool
Faisal Vali
The D programming language already supports strings as templates parameters. Compile time regexes fairly trivial with this featrue (much easier than c++ in any case).
caspin
+5  A: 

As for the language features - pretty much only modules. Well, maybe multiple dispatch as well :). I'd like to see RTTI removed, but of course it cannot happen.

As for the standard library, I'd like to see: more support for international programming (Unicode, localization readiness, calendars, etc), networking, a better IO library, more string manipulation functions (include Boost String Algorithms?), improved support for concurrency, secure integers (something like SafeInt), decimal floating point numbers, big integers. I don't think adding a GUI library makes sense, and I don't want a non-deterministic garbage collector either - even as an option.

Nemanja Trifunovic
your post is a mix of ideas I like and some I don't. I almost didn't upvote you
caspin
+2  A: 

I wouldn't mind seeing a standard way of dealing with time beyond the Unix Epoch. I realize that this might fall under the OS, but I'd like to see it in the standard library. (Does the standard library fall under the c++ spec? I don't know, but the issue needs to be addressed sometime soon, because it isn't too unreasonable to expect embedded systems to still be in use in 20 years or so.)

Caleb Huitt - cjhuitt
Indeed, time is not particularly different from os to os, much the same as local encoding is not specific to the OS, although the OS has some involvement.
TokenMacGuy
Actually, the C++ library leaves this as an implementation detail. The Unix epoch ending in 2038 isn't mandated; an epoch ending in 2012 is also allowed. And defining a date system that work past 9999 is nontrivial.
MSalters
Isn't it just a matter of using an unsigned int, or an Int64?
Charlie Somerville
@MSalters: I didn't necessarily expect it to be trivial, but it has to be done at some point. Besides, how much of the spec really is trivial by this point?
Caleb Huitt - cjhuitt
The planned-but-dropped TR2 was expected to have something based on Boost's date_time library. I expect something along these lines will be back eventually.As to Unix epoch time, overflows are completely optional. Most libcs have already switched to using 64 bit time_t, which won't overflow for a few hundred billion years.
Jack Lloyd
+1  A: 

Here's my wish list:

  • named returns. Many compilers have this, It's a fairly obvious optimisation that can be easily ignored on platforms that can't benefit from it (if there are any?)
  • signatures, ala g++. these are just handy.
  • kernel functions, similar to brook or cuda. without them, it is non-trivial to use any kind of parallelism besides multiple threads.
  • I actually want to see more rtti features. If there was a way to iterate over a type's members, you could implement something like the DRY ORM style of database active records seen in Django or Rails, using pure C++.

and my pony:

  • I'd like a standardized interface that is richer than iostreams. I'm not quite asking for GTKmm (or any other specific or nonspecific gui lib) to go into the standard, but actually, that would be just fine. This is the only one I'm pretty sure won't ever happen, though,
TokenMacGuy
+2  A: 

I want to see all the GC stuff that was cut out of C++0x.

Pavel Minaev
A: 

I want more floating posting types, working with DSPs requires me to write custom assembly classes with hacky unions of floats and fixed points to get the maximum out of the hardware.

  • short float (16bit float)
  • float (32bit float)
  • double (64bit float)
  • long float (128bit float)
LiraNuna
long float is usually 80 bytes, 64 bits mantissa + exponent. Nvidia proposed a half type for c that is essentially your short float.
caspin
This actually sounds like a good idea, many platforms already have support for these datatypes and it's a waste we can't use these datatypes.
Jasper Bekkers
+20  A: 

static reflection

We already small amount of reflection available in the type_traits library. I just want to see more. Essentially I'd like to be able enumerate all members and/or methods at compile time. In my mind it would look a lot like the current function traits.

I described it a more completely in my blog. I've also posted many of the same ideas to comp.lang.c++.moderated.

Just a quick list of benefits from compile time reflection

  • Powerful unit testing tools
  • Good intellisense for external C++ libraries (Boost). The current state of affairs is really pitiful even for Microsofts fabled implementation.
  • Cross compiler intellisense libraries
  • Powerful refactoring tools like those in Java
  • serialization of classes
  • marshalling
  • network byte order swapping of complex structs
  • QT's compiler could be completely implmented compile time instead of with macros and a second compile step
  • there has to be a pile of others.
caspin
There was a proposal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1775.pdf Hopefully its picked up next time.
Georg Fritzsche
+5  A: 

I'd like to see (optional!) statically-checked exception specifications:

void foo () static throw()
{
    throw 1; //ERROR: function marked throw()
}

template <typename T> void bar(T t) throw(auto)
  // will have a specification of every exception it might throw.
{
    return t;
}

There would have to be a whole lot of work to do here, but it would be a fantastically useful feature, and it wouldn't have all the problems that a mandatory checking framework has.

coppro
The problem is that this feature can never be optional. If you do (optionally) define your exception specification, then either you are restricted to only using functions/methods that have exception specifications or else the compiler will not be able to statically check the code.
David Rodríguez - dribeas
@dribeas: you missed the obvious third option - your function (with exception specification) will have to wrap calls to others (without one) with `try/catch`.
Pavel Minaev
@Pavel Minaev: and what would it do if it did catch something. std::unexpected() at run-time?
UncleBens
It would do whatever it wanted to.Ideally, there would also be some way to redeclare library function exception specifications so you weren't forced to do something stupid to wrap a library that doesn't use specifications.
coppro
+1  A: 

Replace it with D.

Avihu Turzion
+1  A: 

I would like to see bignums in c++ std lib. Other languges (LISP, Haskell, Python, Java, C#, Ruby...) already have it.

robson3.14
+2  A: 

First of all, removal of C cruft. No const char* to char* cast anymore, no C-style casts, etc. Even if this means that current C++ code will have to be slightly adapted.

And a bunch more ...

  • Make "foo" actually an array<char, size-known-at-compile-time>
  • Remove redundant keywords (typename/class in template definitions) and redundant ways to define stuff. There should be usually one way to do something, and not two equally good ones (at least for simple stuff).
  • Revamp the string handling. Strings should be encoded using Unicode, with strong conversion functions.
  • Deeper runtime control. Let me reroute all memory allocations to my custom allocator, stuff like this.
  • Cleaned up standard library. binary_search should be replaced with something useful, and the stream classes need an overhaul. They should be byte oriented, and not character oriented, and much simpler than they currently are.
  • Reworked RTTI system, with additions to the standard library to do real introspection. At least, give me a guarantee for getting class names!
  • Standard library split up into more than one namespace.
  • More focus on performance. The STL should inherit some stuff from the EASTL proposal, for example, a useful allocator model. The current one is really problematic at best.
  • Oh well, and of course thread pools and abstractions for parallelism in the standard library.
  • fix vector<bool>
Anteru
C++0x is already reworking the allocator model, and Unicode character types are being added.
jalf
Yes, but the string handling in C++ is very bad compared to .NET/Java/etc. The main problem is the string class -- although it contains a lot of functions, it still lacks basic processing stuff (to_lower?). Boost::StringAlgorithms helps a bit, but I didn't see a reliable way for manipulating UTF strings with C++ (which is tricky, as several bytes may form a single character ...), except of course the ICU library. Ideally, there would be no need for ICU :)
Anteru
In Java and .NET, you may also need several `char`s for a single character, so you have all the same problems, except that they're less obvious (many people don't understand that Java/.NET strings are UTF-16, not UCS2, and what surrogate pairs are).
Pavel Minaev
A: 

All this comments put together look amazingly similar to "D" programming language. Did you know that some very big C++ names are already writing articles on "D" ?

I am afraid "D" will be the end of "C++" if the famous ISO comity is not shaken and stirred and than made up again ...

Dusan (London, UK)

D is missing two critical features before it can be taken seriously: 1) Backwards compatibility with C++ (you don't expect people to just throw away their millions of lines of C++ code just to switch to D, do you? If we're going to throw away our code, why not upgrade to a *really* modern language instead of another incremental improvement?) And 2) general acceptance. Broad compiler support and a stable standard people can work against and get used to, similar to how we've had C++98 for the last decade.
jalf
+11  A: 

Concepts! :)

jalf
+1, I was just going to write the same thing :)
avakar
+1 I can't upvote this hard enough
bdonlan
+1  A: 

A standard library like the one Java or .NET offer.

Geo
+1, with a small edit: A standard library *with functionality* like the one Java or .NET offer.
avakar
Already there: www.qtsoftware.com (well, not in the standard, but neither is Java's or C#'s library).
The problem with Qt is that it has very Java-like look, and doesn't use idiomatic C++ patterns - unlike, for example, Boost. I'd kill for a decent cross-platform Boost-style UI library.
Pavel Minaev
I had the opportunity of testing Qt a bit, but I didn't like it that much. I prefer Swing any time. And Boost has too much C++ magic for my taste.
Geo
A: 

mmm... talking about the new standard name I think if for you all 0x means an hexadecimal number, then it will be C++A or C++a but never C++0A cause this is an invalid octal number and an error compilation in C++ :)

msantamaria
What about C++0xA?
Joe D