Discussion:
constexpr non-static data members?
(too old to reply)
stephan.bergmann.secondary via ISO C++ Standard - Discussion
2018-09-28 11:04:47 UTC
Permalink
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0386r2.pdf>
"Inline Variables" removed from [dcl.constexpr] the requirement that
constexpr shall only be applied to "[...] or the declaration of a static
data member of a literal type" (in its place adding a sentence about
constexpr functions and static data members implicitly being inline). I'm
puzzled whether that removal means that non-static data members can be
constexpr now (though I wouldn't see any immediate benefit of that, and at
least trunk versions of Clang and GCC still reject such), or whether
that's still forbidden through some wording in other places of the
standard. (It's never been too clear to me whether non-static data members
are actually covered by the definition of "variable" in the standard or
not.)
--
---
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+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Nicolas Lesser
2018-09-28 11:42:37 UTC
Permalink
On Fri, Sep 28, 2018, 1:04 PM stephan.bergmann.secondary via ISO C++
Post by stephan.bergmann.secondary via ISO C++ Standard - Discussion
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0386r2.pdf>
"Inline Variables" removed from [dcl.constexpr] the requirement that
constexpr shall only be applied to "[...] or the declaration of a static
data member of a literal type" (in its place adding a sentence about
constexpr functions and static data members implicitly being inline). I'm
puzzled whether that removal means that non-static data members can be
constexpr now (though I wouldn't see any immediate benefit of that, and at
least trunk versions of Clang and GCC still reject such), or whether
that's still forbidden through some wording in other places of the
standard. (It's never been too clear to me whether non-static data members
are actually covered by the definition of "variable" in the standard or
not.)
Yes that's it. A variable is not a data member. See also [basic]p6. The
sentence was only removed because it restricted constexpr static variables
to be of literal type, which wasn't needed anymore with inline variables.
Post by stephan.bergmann.secondary via ISO C++ Standard - 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
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+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Continue reading on narkive:
Loading...