开发者

What do you dislike most about some of your favorite C++0x features? [closed]

开发者 https://www.devze.com 2022-12-16 11:55 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 12 years ago.

While I am excited that C++0x will be much more fun to program in than C++98, I sometimes feel that some of the new features leave something important to be desired.

For e.g. initializer lists can not be deduced as references to arrays, variadic templates don't allow for member packs or arbitrary expression expansion, local classes can't be templates or contain templates or have in-class member initializers, lambdas can't be templates, constexpr can't help with compile time processing of string literals, user defined string literals can't be templates (whereas user defined number literals can be), decltype behaves significantly different in certain cases based on whether you parenthesize its operand or not (would have preferred a separate 'exprtype').

I recognize that the standard's committee had to make some very difficult choices and compromises (since it really isn't meant to innovate, and because it has fairly limited resources), and I respect them deeply and am very grateful to them for doing what they do. This post isn't meant to denigrate their efforts (I am very much looking forward to using C++0x) - but to gauge how strongly others feel about some of these features.

With that in mind, I pose to you the following questions:

1) What are the new features that you are completely satisfied with?

2) What are the new features that you are partially satisfied with - and what would it take to make you more satisfied?

3) What are the new features that you wish had definitely not been added?

For a list of all the 开发者_如何学Gofeatures, I will refer you to Stroustrup's List.

Thanks!


I'm very annoyed by many things in C++0x. All of them from the same reason -- while the new features are absolutely brilliant, the need of backwards-compatibility makes many of them look like ugly hacks...

Example 1:

SequenceClass(std::initializer_list<int> list);

instead of

SequenceClass(int... list); // or other nice in-language way

Example 2:

class D [[base_check]] : public B {
    void sone_func1 [[override]] ();

instead of

class D : public B {
    override void sone_func1 ();

Example 3:

std::shared_ptr<Target> m_target;

instead of

Target ^ m_target;

... okay, that last one is my own happiness :>

Of course all of these are subjective -- many people prefer it otherwise. What annoys me is the fact that we have to keep backwards compatibility so the language can't fully evolve. This is ESPECIALLY annoying in cases of safety -- I'd really like to see C-style casts go away...

I really hope that C++ will someday adapt a "deprecation" mechanism, akin to what Khronos did to OpenGL since 2.0.


It's good they have alignment and memory model and thread local stuff. That should have been in ten years ago and there's no reason it should have taken so long.

The delegating constructors is something I wanted forever, but the implementation is horrible. If that's the best they can do it should be removed.

Pretty much everything else is just added complication and yet more initializer list nonsense. Which is why it's impossible to make delegating constructors properly. They should be trying to simplify the language, not add yet more metaprogramming complexity that makes so many problems.


  1. lambdas, auto, rvalue references
  2. templated typedefs; I think the syntax is awkward, but I'm glad they exist in some form
  3. Concepts. Oh wait... I win
0

精彩评论

暂无评论...
验证码 换一张
取 消