I propose to allow custom move constructors and move assignment operators, particularly if they are defined as moves of each member and base class (i.e. equivalent to the default).For efficiency reasons, we should be able to move types that simply compose other move-only types such asstruct T {scoped_ptr<A> a;scoped_ptr<B> b;};This allows us to to use these types in STL containers without indirecting through a scoped_ptr<>.As noted in an earlier thread ("default move ctor and [chromium-style] Complex class/struct needs an explicit out-of-line destructor"), our clang plugin requires an out-of-line constructor & destructor for the above struct
, so in practice we'll need to define the ctors & dtor out-of-line:struct T {T(scoped_ptr<A> a, scoped_ptr<B> b);T(T&& other);T& operator=(T&& other);~T();scoped_ptr<A> a;scoped_ptr<B> b;};T::T(scoped_ptr<A> a, scoped_ptr<B> b) : a(std::move(a)), b(std::move(b)) {}T::T(T&& other) : a(std::move(other.a)), b(std::move(other.b)) {}T& T::operator=(T&& other) { a = std::move(other.a); b = std::move(other.b); return *this; }T::~T() {}Also, we would use "= default" to define the move ctor if it were implemented correctly in MSVC2013.Cheers!Michael
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAC5F_1kaq3u7XaEhs%2BPn3cHnT66ZdO%3Dnrz2c9xeAdui9JjrnGw%40mail.gmail.com.
On Thu, Nov 19, 2015 at 10:51 AM, Michael Spang <sp...@chromium.org> wrote:I propose to allow custom move constructors and move assignment operators, particularly if they are defined as moves of each member and base class (i.e. equivalent to the default).For efficiency reasons, we should be able to move types that simply compose other move-only types such asstruct T {scoped_ptr<A> a;scoped_ptr<B> b;};This allows us to to use these types in STL containers without indirecting through a scoped_ptr<>.As noted in an earlier thread ("default move ctor and [chromium-style] Complex class/struct needs an explicit out-of-line destructor"), our clang plugin requires an out-of-line constructor & destructor for the above structWasn't the conclusion on that thread that we could fix this in the plugin instead? (Sorry, behind on email.)In general, I'm pretty scared of allowing custom move constructors/assignment operators generally, and it looks like the motivating thing for this proposal could possibly fixed without allowing them.
--, so in practice we'll need to define the ctors & dtor out-of-line:struct T {T(scoped_ptr<A> a, scoped_ptr<B> b);T(T&& other);T& operator=(T&& other);~T();scoped_ptr<A> a;scoped_ptr<B> b;};T::T(scoped_ptr<A> a, scoped_ptr<B> b) : a(std::move(a)), b(std::move(b)) {}T::T(T&& other) : a(std::move(other.a)), b(std::move(other.b)) {}T& T::operator=(T&& other) { a = std::move(other.a); b = std::move(other.b); return *this; }T::~T() {}Also, we would use "= default" to define the move ctor if it were implemented correctly in MSVC2013.Cheers!Michael
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAC5F_1kaq3u7XaEhs%2BPn3cHnT66ZdO%3Dnrz2c9xeAdui9JjrnGw%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAMGbLiE1_AFnGZx7GXmd7fJfhnOX5TgL-GOMMiq69xBfwXd16w%40mail.gmail.com.
On Thu, Nov 19, 2015 at 2:49 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 10:51 AM, Michael Spang <sp...@chromium.org> wrote:I propose to allow custom move constructors and move assignment operators, particularly if they are defined as moves of each member and base class (i.e. equivalent to the default).For efficiency reasons, we should be able to move types that simply compose other move-only types such asstruct T {scoped_ptr<A> a;scoped_ptr<B> b;};This allows us to to use these types in STL containers without indirecting through a scoped_ptr<>.As noted in an earlier thread ("default move ctor and [chromium-style] Complex class/struct needs an explicit out-of-line destructor"), our clang plugin requires an out-of-line constructor & destructor for the above structWasn't the conclusion on that thread that we could fix this in the plugin instead? (Sorry, behind on email.)In general, I'm pretty scared of allowing custom move constructors/assignment operators generally, and it looks like the motivating thing for this proposal could possibly fixed without allowing them.Dana suggested that if we could not define our own move operators for custom types, we could not rely on implicitly defined ones for those types either. With that interpretation (which we can certainly debate), fixing the plugin is not enough.Also, the Google C++ style guide allows defining move operations. We should eventually be consistent with that.
On Thu, Nov 19, 2015 at 11:55 AM, Michael Spang <sp...@chromium.org> wrote:On Thu, Nov 19, 2015 at 2:49 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 10:51 AM, Michael Spang <sp...@chromium.org> wrote:I propose to allow custom move constructors and move assignment operators, particularly if they are defined as moves of each member and base class (i.e. equivalent to the default).For efficiency reasons, we should be able to move types that simply compose other move-only types such asstruct T {scoped_ptr<A> a;scoped_ptr<B> b;};This allows us to to use these types in STL containers without indirecting through a scoped_ptr<>.As noted in an earlier thread ("default move ctor and [chromium-style] Complex class/struct needs an explicit out-of-line destructor"), our clang plugin requires an out-of-line constructor & destructor for the above structWasn't the conclusion on that thread that we could fix this in the plugin instead? (Sorry, behind on email.)In general, I'm pretty scared of allowing custom move constructors/assignment operators generally, and it looks like the motivating thing for this proposal could possibly fixed without allowing them.Dana suggested that if we could not define our own move operators for custom types, we could not rely on implicitly defined ones for those types either. With that interpretation (which we can certainly debate), fixing the plugin is not enough.Also, the Google C++ style guide allows defining move operations. We should eventually be consistent with that.Yes, eventually, but in my opinion not 2 days after we started allowing std::move().
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAMGbLiFqsVmnGry7sVhyEdiXV2ENVq5djW96DOhR49o00s%3DQmQ%40mail.gmail.com.
On Thu, Nov 19, 2015 at 2:57 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 11:55 AM, Michael Spang <sp...@chromium.org> wrote:On Thu, Nov 19, 2015 at 2:49 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 10:51 AM, Michael Spang <sp...@chromium.org> wrote:I propose to allow custom move constructors and move assignment operators, particularly if they are defined as moves of each member and base class (i.e. equivalent to the default).For efficiency reasons, we should be able to move types that simply compose other move-only types such asstruct T {scoped_ptr<A> a;scoped_ptr<B> b;};This allows us to to use these types in STL containers without indirecting through a scoped_ptr<>.As noted in an earlier thread ("default move ctor and [chromium-style] Complex class/struct needs an explicit out-of-line destructor"), our clang plugin requires an out-of-line constructor & destructor for the above structWasn't the conclusion on that thread that we could fix this in the plugin instead? (Sorry, behind on email.)In general, I'm pretty scared of allowing custom move constructors/assignment operators generally, and it looks like the motivating thing for this proposal could possibly fixed without allowing them.Dana suggested that if we could not define our own move operators for custom types, we could not rely on implicitly defined ones for those types either. With that interpretation (which we can certainly debate), fixing the plugin is not enough.Also, the Google C++ style guide allows defining move operations. We should eventually be consistent with that.Yes, eventually, but in my opinion not 2 days after we started allowing std::move().Shrug, I guess it's not a big deal if we wait on this due to an excess of caution in allowing new features.
On Thu, Nov 19, 2015 at 12:06 PM, Michael Spang <sp...@chromium.org> wrote:On Thu, Nov 19, 2015 at 2:57 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 11:55 AM, Michael Spang <sp...@chromium.org> wrote:On Thu, Nov 19, 2015 at 2:49 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 10:51 AM, Michael Spang <sp...@chromium.org> wrote:I propose to allow custom move constructors and move assignment operators, particularly if they are defined as moves of each member and base class (i.e. equivalent to the default).For efficiency reasons, we should be able to move types that simply compose other move-only types such asstruct T {scoped_ptr<A> a;scoped_ptr<B> b;};This allows us to to use these types in STL containers without indirecting through a scoped_ptr<>.As noted in an earlier thread ("default move ctor and [chromium-style] Complex class/struct needs an explicit out-of-line destructor"), our clang plugin requires an out-of-line constructor & destructor for the above structWasn't the conclusion on that thread that we could fix this in the plugin instead? (Sorry, behind on email.)In general, I'm pretty scared of allowing custom move constructors/assignment operators generally, and it looks like the motivating thing for this proposal could possibly fixed without allowing them.Dana suggested that if we could not define our own move operators for custom types, we could not rely on implicitly defined ones for those types either. With that interpretation (which we can certainly debate), fixing the plugin is not enough.Also, the Google C++ style guide allows defining move operations. We should eventually be consistent with that.Yes, eventually, but in my opinion not 2 days after we started allowing std::move().Shrug, I guess it's not a big deal if we wait on this due to an excess of caution in allowing new features.I take issue with "an excess of caution". There are people who are super excited about all this new stuff – which is great! But there are also people who choose to invest their time differently. Almost by definition, this list is populated almost exclusively by the former. The idea behind this gradual roll-out process is that new stuff arrives gradually, so that people who don't read up on all the New Stuff on their own initiative can get used to it somewhat more slowly, while people who do know all about the New Stuff still get to use at least some of it immediately. So yes, this is cautious, but given that we have hundreds of engineers working on the project I'd argue that it's not an excess of caution.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAMGbLiHVkRgW1ULm8yd%2BRthL%2BOrjz1LbYdY67PDnMp-wU%3DoY9A%40mail.gmail.com.
On Thu, Nov 19, 2015 at 12:06 PM, Michael Spang <sp...@chromium.org> wrote:On Thu, Nov 19, 2015 at 2:57 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 11:55 AM, Michael Spang <sp...@chromium.org> wrote:On Thu, Nov 19, 2015 at 2:49 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 10:51 AM, Michael Spang <sp...@chromium.org> wrote:I propose to allow custom move constructors and move assignment operators, particularly if they are defined as moves of each member and base class (i.e. equivalent to the default).For efficiency reasons, we should be able to move types that simply compose other move-only types such asstruct T {scoped_ptr<A> a;scoped_ptr<B> b;};This allows us to to use these types in STL containers without indirecting through a scoped_ptr<>.As noted in an earlier thread ("default move ctor and [chromium-style] Complex class/struct needs an explicit out-of-line destructor"), our clang plugin requires an out-of-line constructor & destructor for the above structWasn't the conclusion on that thread that we could fix this in the plugin instead? (Sorry, behind on email.)In general, I'm pretty scared of allowing custom move constructors/assignment operators generally, and it looks like the motivating thing for this proposal could possibly fixed without allowing them.Dana suggested that if we could not define our own move operators for custom types, we could not rely on implicitly defined ones for those types either. With that interpretation (which we can certainly debate), fixing the plugin is not enough.Also, the Google C++ style guide allows defining move operations. We should eventually be consistent with that.Yes, eventually, but in my opinion not 2 days after we started allowing std::move().Shrug, I guess it's not a big deal if we wait on this due to an excess of caution in allowing new features.I take issue with "an excess of caution". There are people who are super excited about all this new stuff – which is great! But there are also people who choose to invest their time differently. Almost by definition, this list is populated almost exclusively by the former. The idea behind this gradual roll-out process is that new stuff arrives gradually, so that people who don't read up on all the New Stuff on their own initiative can get used to it somewhat more slowly, while people who do know all about the New Stuff still get to use at least some of it immediately. So yes, this is cautious, but given that we have hundreds of engineers working on the project I'd argue that it's not an excess of caution.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAMGbLiHVkRgW1ULm8yd%2BRthL%2BOrjz1LbYdY67PDnMp-wU%3DoY9A%40mail.gmail.com.
On Thu, Nov 19, 2015 at 3:14 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 12:06 PM, Michael Spang <sp...@chromium.org> wrote:On Thu, Nov 19, 2015 at 2:57 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 11:55 AM, Michael Spang <sp...@chromium.org> wrote:On Thu, Nov 19, 2015 at 2:49 PM, Nico Weber <tha...@chromium.org> wrote:On Thu, Nov 19, 2015 at 10:51 AM, Michael Spang <sp...@chromium.org> wrote:I propose to allow custom move constructors and move assignment operators, particularly if they are defined as moves of each member and base class (i.e. equivalent to the default).For efficiency reasons, we should be able to move types that simply compose other move-only types such asstruct T {scoped_ptr<A> a;scoped_ptr<B> b;};This allows us to to use these types in STL containers without indirecting through a scoped_ptr<>.As noted in an earlier thread ("default move ctor and [chromium-style] Complex class/struct needs an explicit out-of-line destructor"), our clang plugin requires an out-of-line constructor & destructor for the above structWasn't the conclusion on that thread that we could fix this in the plugin instead? (Sorry, behind on email.)In general, I'm pretty scared of allowing custom move constructors/assignment operators generally, and it looks like the motivating thing for this proposal could possibly fixed without allowing them.Dana suggested that if we could not define our own move operators for custom types, we could not rely on implicitly defined ones for those types either. With that interpretation (which we can certainly debate), fixing the plugin is not enough.Also, the Google C++ style guide allows defining move operations. We should eventually be consistent with that.Yes, eventually, but in my opinion not 2 days after we started allowing std::move().Shrug, I guess it's not a big deal if we wait on this due to an excess of caution in allowing new features.I take issue with "an excess of caution". There are people who are super excited about all this new stuff – which is great! But there are also people who choose to invest their time differently. Almost by definition, this list is populated almost exclusively by the former. The idea behind this gradual roll-out process is that new stuff arrives gradually, so that people who don't read up on all the New Stuff on their own initiative can get used to it somewhat more slowly, while people who do know all about the New Stuff still get to use at least some of it immediately. So yes, this is cautious, but given that we have hundreds of engineers working on the project I'd argue that it's not an excess of caution.I apologize, I don't mean to insult to the process. I think the we have the right motivations in rolling out incrementally.std::move() on STL and base/ types and std::move() on user types are very closely related, so rolling them out as a unit makes sense to me. I'd argue we should roll out both the tools to consume movable types as well as compose them at the same time - the hard part is the concept, not the syntax.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAC5F_1kq%3D7n_1Y9T9UmCSOhpjNg%2Bze04gKq2%2B_LbWSm4DjwRUA%40mail.gmail.com.