Workshop and Discussion Group: Pitfalls of defaulted-default ctors

Please let us know if you are interesting in giving a lightning talk or leading a discussion.


Join or login to comment.

  • Patrick L.

    Re: '..."=default" disabling the ability to make a "const" variable without explicit initializer'

    But if you remove the "=default" declaration, you still cannot make a "const" variable without an initializer... So this particular stupidity is just inherited from C++03, right?

    Re: 'What if the constructor is defined out-of-line but with the "inline" keyword?'

    Same as any other out-of-line definition with the "inline" keyword. This is one of my "first world language problems" with C++: "inline" has nothing to do with inlining! The compiler can inline a function you do not declare inline, and it can generate external code for a function you do declare inline.

    The "inline" keyword is a linkage specifier and nothing more. It lets you provide the same definition in multiple translation units without violating the One Definition Rule (aka. avoiding multiply-defined symbols at link time).

    I am sure you know all this already, but I bet some people don't :-)

    August 28, 2014

  • Arthur O.

    A while back, I started making a list of "stupidities in C++11" that I'd noticed. I only put two things on the list so far. And BOTH of them came up in last night's meeting! (That is: "=default" disabling the ability to make a "const" variable without explicit initializer, and self-move/self-swap not working on standard container types.)

    Re self-swap, I forgot to mention that even though you might naively expect std::swap(x,x) to "just work" — because it moves x's value out, undefinedly moves x into itself, and then moves x's old value back in — it turns out that libc++ in _LIBCPP_DEBUG mode actually *assert-fails at runtime* on the "undefinedly move..." part!

    Excellent lightning talk by Jared. One more case to muddy the waters with: What if the constructor is defined out-of-line but with the "inline" keyword? ;)

    August 28, 2014

    • Dane Van D.

      Does "=default" disable the ability to make a "const" variable without explicit initialiser? Isn't a trailing '()' required in the declaration whether "=default" is explicitly specified or not?

      August 28, 2014

    • Arthur O.

      struct Tag { Tag() {} }; const Tag t; // accepted
      struct Tag2 { }; const Tag2 t2; // rejected
      struct Tag3 { Tag3() = default; }; const Tag3 t3; // rejected

      It would be great if all three were accepted, IMO.
      DR 253 covers this case; it's been around for a while.
      http://www.open-std.o...­ (about halfway down the humongous page)

      August 28, 2014

  • Dane Van D.

    Had fun last night. Looking forward to the next one.

    August 28, 2014

  • Jon K.

    Great discussion!

    August 28, 2014

  • Dane Van D.

    We don't have any set content for tomorrow's meeting. Does anyone want to present something? If not, should we cancel or just wing it?

    August 26, 2014

    • Dane Van D.

      Maybe you can give us an update on cppcon?

      August 26, 2014

    • Jon K.

      Try and stop me. ;-)

      August 27, 2014

  • Dane Van D.

    Thanks, all. See you tomorrow!

    August 26, 2014

  • Jared

    I plan to have a short thing prepared on pitfalls of defaulted-default ctors.

    August 26, 2014

  • Kishore P.

    I am excited to meet you all. Could you please let me know the agenda of the workshop on August 27. Thank you.

    August 24, 2014

Our Sponsors

People in this
Meetup are also in:

Sometimes the best Meetup Group is the one you start

Get started Learn more
Rafaël

We just grab a coffee and speak French. Some people have been coming every week for months... it creates a kind of warmth to the group.

Rafaël, started French Conversation Group

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy