--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
FWIW I agree with you, since this is fine:And it seems to me that it should do exactly the same thing.auto f=[a=a]() mutable { ++a; }; // ok
On Sun, 29 Jul 2018 at 22:01, <victor.kh...@gmail.com> wrote:
--Consider:const int a=1;auto f=[a]() mutable { ++a; } // error: the type of closure's member is const intint a_copy=a;auto f=[a_copy]() mutable { ++a_copy; } // OK nowSo copying an object is different from copying a copy of an object, which seems wrong.From cppreference: The type of each data member is the type of the corresponding captured entity, except if the entity has reference type (in that case, references to functions are captured as lvalue references to the referenced functions, and references to objects are captured as copies of the referenced objects).I think this should be changed to the decayed types.Any opinions?Victor.
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
I sort of agree, but this change would make the type of a depend on whether it's being odr-used or not (note that non-odr-uses of a refer to the enclosing entity, not the captured value), which seems unfortunate. Since in C++14 we have the workaround posted by Richard, perhaps it's best to just let this be.
On Sun, Jul 29, 2018 at 3:43 PM, Richard Hodges <hodg...@gmail.com> wrote:
FWIW I agree with you, since this is fine:And it seems to me that it should do exactly the same thing.auto f=[a=a]() mutable { ++a; }; // ok
On Sun, 29 Jul 2018 at 22:01, <victor.kh...@gmail.com> wrote:
--Consider:const int a=1;auto f=[a]() mutable { ++a; } // error: the type of closure's member is const intint a_copy=a;auto f=[a_copy]() mutable { ++a_copy; } // OK nowSo copying an object is different from copying a copy of an object, which seems wrong.From cppreference: The type of each data member is the type of the corresponding captured entity, except if the entity has reference type (in that case, references to functions are captured as lvalue references to the referenced functions, and references to objects are captured as copies of the referenced objects).I think this should be changed to the decayed types.Any opinions?Victor.
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
--
--Brian Bi
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.
Current rule allows
const int length = 42;
[=]() mutable { int array[length]; };
The proposed rule will make that either invalid or extra tricky.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
You received this message because you are subscribed to a topic in the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.org/d/topic/std-discussion/FAb7nRfmU3I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to std-discussio...@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.