id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
cpp_utility/0eQsx6ip1DwJpli1_134_0.txt
But why are we stuck with the keyword? For object declarations I think it makes perfect sense, even if a similar argument could be applied that the compiler already knows a constant when it sees one. For functions, though, it deceptively fails to fulfill its apparent (to the uninformed) guarantee.
cpp_utility/76362_91_0.txt
Copy link
cpp_utility/0eQsx6ip1DwJpli1_248_0.txt
Daryle W.
cpp_utility/constexprarraysize_50_0.txt
We’d have to make the constraint something like the following (other constraints omitted for brevity, like making sure the range is actually contiguous and having the right underlying type):
cpp_utility/0eQsx6ip1DwJpli1_88_0.txt
There's no rationale mentioned there. I can imagine it's in the interest of standardization, that implementation divergence on this point defeats the purpose of having a common standard in the first place. But it would be good to have some kind of indication besides "it was debated and opposite decision was made."
cpp_utility/0eQsx6ip1DwJpli1_204_0.txt
Reply to author
cpp_utility/constexprarraysize_67_0.txt
All this ` constexpr ` machinery, and the best we can do is really only a little bit better than C.
cpp_utility/CanIconstexpranstdar_33_0.txt
A constexpr variable’s initializer must be computable at compile time. The constexpr specifier insists to the compiler this be true. If the compiler cannot evaluate the variable’s initializer, i
cpp_utility/0eQsx6ip1DwJpli1_283_0.txt
Sign in to report message
cpp_utility/constexprarraysize_105_0.txt
Why were abbrev. lambdas rejected?
cpp_utility/constexprarraysize_84_0.txt
But _even then_ , we’re still stuck. We still have what I’m calling the vector ` push_back() ` / ` emplace_back() ` problem (I first pointed this out in D2089). How can we make all of these work:
cpp_utility/0eQsx6ip1DwJpli1_56_0.txt
Delete
cpp_utility/76362_5_0.txt
* Product
cpp_utility/0eQsx6ip1DwJpli1_82_0.txt
Report message
cpp_utility/0eQsx6ip1DwJpli1_209_0.txt
You do not have permission to delete messages in this group
cpp_utility/0eQsx6ip1DwJpli1_14_0.txt
# Draft N3690 : Why is reference std::array::operator[] not constexpr ?
cpp_utility/0eQsx6ip1DwJpli1_129_0.txt
Show original message
cpp_utility/76362_81_0.txt
###
cpp_utility/CanIconstexpranstdar_6_0.txt
The Royal family has been investing a portion o
cpp_utility/0eQsx6ip1DwJpli1_8_0.txt
[ Groups ](./my-groups "Groups")
cpp_utility/76362_56_0.txt
# constexpr std::array out-of-bounds array index access compiles without warnings or errors #76362
cpp_utility/76362_12_0.txt
By Solution
cpp_utility/cpp_classes_1_5.txt
nt link ](/mwiki/index.php?title=cpp/utility/tuple_size&oldid=152393 "Permanent link to this revision of the page") * [ Page information ](/mwiki/index.php?title=cpp/utility/tuple_size&action=info) * In other languages * [ Deutsch ](http://de.cppreference.com/w/cpp/utility/tuple_size "cpp/utility/tuple size") ...
cpp_utility/0eQsx6ip1DwJpli1_36_0.txt
constexpr int baz () { std :: array < int , 4 > i = { 1 , 2 , 3 , 4 }; i [ 0 ]= i [ 1 ]; // error reference operator[] is not constexpr return i [ 0 ]; }
cpp_utility/0eQsx6ip1DwJpli1_28_0.txt
Report message
cpp_utility/0eQsx6ip1DwJpli1_145_0.txt
Sign in to forward
cpp_utility/76362_111_0.txt
Assignees
cpp_utility/0eQsx6ip1DwJpli1_213_0.txt
Show original message
cpp_utility/0eQsx6ip1DwJpli1_182_0.txt
### Daryle Walker
cpp_utility/76362_93_0.txt
###
cpp_utility/0eQsx6ip1DwJpli1_130_0.txt
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
cpp_utility/0eQsx6ip1DwJpli1_289_0.txt
I'm a bit concerned, relaxed constrexpr was voted into the core language more than one year ago, but library like std::array are not updated yet.
cpp_utility/constexprarraysize_23_0.txt
All of these compilers are actually correct to reject this example. The reason is that in order for ` array_size(param) ` to work, we have to pass that reference to ` param ` into ` array_size ` \- and that involves “reading” the reference. The specific rule we’re violating is [ [expr.const]/5.12 ](https://timsong-cpp....
cpp_utility/76362_48_0.txt
[ Sign up for GitHub ](/signup?return_to=%2Fllvm%2Fllvm- project%2Fissues%2Fnew%2Fchoose)
cpp_utility/76362_9_0.txt
* Solutions
cpp_utility/76362_6_0.txt
* [ Actions Automate any workflow ](https://github.com/features/actions) * [ Packages Host and manage packages ](https://github.com/features/packages) * [ Security Find and fix vulnerabilities ](https://github.com/features/security) * [ Codespaces Instant dev environments ](https://github.com/features/codespace...
cpp_utility/0eQsx6ip1DwJpli1_126_0.txt
Copy link
cpp_utility/76362_88_0.txt
Sorry, something went wrong.
cpp_utility/constexprarraysize_49_0.txt
How could we make this work?
cpp_utility/0eQsx6ip1DwJpli1_13_0.txt
[ Privacy ](https://policies.google.com/privacy?hl=en_US) • [ Terms ](https://policies.google.com/terms?hl=en_US)
cpp_utility/constexprarraysize_12_0.txt
**Update from 2022** : my proposal to address this problem, [ P2280 ](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2280r4.html) (Using unknown pointers and references in constant expressions ), has been adopted for C++23.
cpp_utility/0eQsx6ip1DwJpli1_25_0.txt
Delete
cpp_utility/76362_17_0.txt
* [ GitHub Sponsors Fund open source developers ](https://github.com/sponsors)
cpp_utility/constexprarraysize_3_0.txt
* [ __ HOME ](/) * [ __ TAGS ](/tags/) * [ __ ARCHIVES ](/archives/) * [ __ ABOUT ](/about/)
cpp_utility/CanIconstexpranstdar_32_0.txt
Variables
cpp_utility/0eQsx6ip1DwJpli1_141_0.txt
Oct 13, 2013, 10:53:46 PM 10/13/13
cpp_utility/cpp_classes_5_1.txt
alue_reference "cpp/types/is lvalue reference") (C++11) [ is_rvalue_reference ](/w/cpp/types/is_rvalue_reference "cpp/types/is rvalue reference") (C++11) [ is_member_pointer ](/w/cpp/types/is_member_pointer "cpp/types/is member pointer") (C++11) [ is_member_object_pointer ](/w/cpp/types/is_member_object_pointe...
cpp_utility/0eQsx6ip1DwJpli1_156_0.txt
The Standards usually change only when someone makes a proposal, champions it, convinces the committee, and it is adopted.
cpp_utility/CanIconstexpranstdar_7_0.txt
Profile photo for David Vandevoorde David Vandevoorde C++ committee and direction group memberAuthor has 1.2K answers and 11.1M answer views · Updated 3y Related How do I use the C++20 constexpr std::vector? Originally Answered: How do I use the C++20 constexpr std: :vector? Before I answer that let me remind you of tw...
cpp_utility/CanIconstexpranstdar_13_0.txt
Every team is different, so your team might not use Asana exactly like my team does. But every team can benefit from more clarity, coordination, and collaboration at work. Here are f
cpp_utility/0eQsx6ip1DwJpli1_193_0.txt
Sign in to report message
cpp_utility/0eQsx6ip1DwJpli1_15_0.txt
571 views
cpp_utility/76362_4_0.txt
[ Sign in ](/login?return_to=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm- project%2Fissues%2F76362)
cpp_utility/0eQsx6ip1DwJpli1_267_0.txt
Thanks Daniel,
cpp_utility/0eQsx6ip1DwJpli1_131_0.txt
to std-dis...@isocpp.org
cpp_utility/76362_2_0.txt
Toggle navigation
cpp_utility/76362_105_0.txt
**[ dyumin ](/dyumin) ** commented Dec 27, 2023
cpp_utility/CanIconstexpranstdar_8_0.txt
A constant expression: An expression that can be evaluated at compile time and whose value can then be used at run time. A core constant expression: An expression that can be evaluated at compile time. To understand the distinction, consider this example:
cpp_utility/76362_32_0.txt
## Use saved searches to filter your results more quickly
cpp_utility/constexprarraysize_106_0.txt
](/c++/2020/01/15/abbrev-lambdas/) [
cpp_utility/CanIconstexpranstdar_1_0.txt
C++17 has so much functionality available at compile time that you don’t need template metaprogramming nearly so often. As long as you stick to recursion, tuples and parameter packs, concatenation, fold expressions and other compile-time constructs, you can do quite sophisticated things with the same template code that...
cpp_utility/cpp_classes_4_3.txt
/tuple_element&action=edit&section=1 "Edit section: Member types") ] Member types Member type | Definition ---|--- ` type ` | ` T1 ` if ` I == 0 ` ` T2 ` if ` I == 1 ` ### [ [ edit ](/mwiki/index.php?title=cpp/utility/pair/tuple_element&action=edit&section=2 "Edit section: Possible implementation") ]...
cpp_utility/0eQsx6ip1DwJpli1_210_0.txt
Copy link
cpp_utility/76362_95_0.txt
Undefined behavior is ill-formed in a constant expression context but in this case ` return Array[3] ` does not force constant evaluation. The following would tough: [ https://godbolt.org/z/8E75KcGsM ](https://godbolt.org/z/8E75KcGsM)
cpp_utility/0eQsx6ip1DwJpli1_75_0.txt
Reply to author
cpp_utility/0eQsx6ip1DwJpli1_200_0.txt
![Richard Smith's profile photo](//lh3.googleusercontent.com/a-/ALV- UjVC7blAB80mIbhTKPoc-3vWfAZ_ewLvg7MoNQcK4MzowYS5qmpr=s40-c)
cpp_utility/76362_104_0.txt
###
cpp_utility/0eQsx6ip1DwJpli1_162_0.txt
Reply to author
cpp_utility/constexprarraysize_39_0.txt
constexpr T* begin() const { return ptr; } constexpr T* end() const { return ptr + size; } constexpr size_t size() const { return size; } };
cpp_utility/0eQsx6ip1DwJpli1_235_0.txt
You do not have permission to delete messages in this group
cpp_utility/CanIconstexpranstdar_31_0.txt
Let’s examine some aspects of the three places constexpr can be used.
cpp_utility/0eQsx6ip1DwJpli1_113_0.txt
Fast backward to 2003. When the notion of generalized constant expression function was proposed, there was no keyword; I was confident that none was needed as long as these functions were required to be inline. However, various people -- implementers, in particular -- insisted on a keyword to alert them in advance tha...
cpp_utility/constexprarraysize_107_0.txt
Implementing span's comparisons
cpp_utility/CanIconstexpranstdar_39_0.txt
Profile photo for Brian Bi Brian Bi software engineerAuthor has 4.7K answers and 59.4M answer views · 5y Related Can someone help explain C++’s `constexpr`? If a variable is declared constexpr, it means that the programmer agrees to accept certain restrictions to ensure that the compiler can evaluate the variable at co...
cpp_utility/0eQsx6ip1DwJpli1_112_0.txt
I am not sure what you mean by this: (1) that you are unaware of how the constexpr keyword came to be? or (2) that you know the history but you just refuse to understand it?
cpp_utility/0eQsx6ip1DwJpli1_19_0.txt
unread,
cpp_utility/constexprarraysize_8_0.txt
# The constexpr array size problem
cpp_utility/0eQsx6ip1DwJpli1_223_0.txt
>> `
cpp_utility/0eQsx6ip1DwJpli1_4_0.txt
Help
cpp_utility/cpp_tag_2_2.txt
on vocabulary types | [ pair ](/w/cpp/utility/pair "cpp/utility/pair") --- [ tuple ](/w/cpp/utility/tuple "cpp/utility/tuple") (C++11) [ optional ](/w/cpp/utility/optional "cpp/utility/optional") (C++17) [ any ](/w/cpp/utility/any "cpp/utility/any") (C++17) [ variant ](/w/cpp/utility/variant "cpp/util...
cpp_utility/CanIconstexpranstdar_18_0.txt
constexpr auto sum = srd::accumulate( myConstArray.begin(), myConstArray.end(), 0);
cpp_utility/76362_94_0.txt
**[ shafik ](/shafik) ** commented Dec 27, 2023
cpp_utility/76362_23_0.txt
# Search code, repositories, users, issues, pull requests...
cpp_utility/constexprarraysize_37_0.txt
constexpr T* begin() { return ptr; } constexpr T* end() { return ptr + Extent; } constexpr size_t size() const { return Extent; } };
cpp_utility/CanIconstexpranstdar_5_0.txt
But this $1 billion estate is nothing compared to the $10 billion that King Charles received tax free, thanks to a clever investment by the Queen into one of the world’s most exclusive asset classes … fine art.
cpp_utility/constexprarraysize_2_0.txt
Just a blog about C++
cpp_utility/0eQsx6ip1DwJpli1_178_0.txt
It affects when a function template specialization is instantiated (constexpr function template specializations may need to be instantiated if they're called in unevaluated contexts; the same is not true for non-constexpr functions since a call to one can never be part of a constant expression). If we removed the meani...
cpp_utility/constexprarraysize_38_0.txt
// dynamic-extent: size is variable, needs to store // both pointer and size template <typename T> struct span<T, dynamic_extent> { T* ptr; size_t size;
cpp_utility/0eQsx6ip1DwJpli1_266_0.txt
> The fact that std::array is applying constexpr to the const overloads > alone is simply a consequence of the fact that the proposing paper was > written at a time, where the rules were different and would not have > allowed that. Fixing the inconsistent difference of constexpr > non-static member functions versus...
cpp_utility/0eQsx6ip1DwJpli1_72_0.txt
### David Krauss
cpp_utility/0eQsx6ip1DwJpli1_296_0.txt
Clear search
cpp_utility/constexprarraysize_4_0.txt
__ [ __ ](https://github.com/brevzin) [ __ ](https://twitter.com/BarryRevzin) [ __ ](https://stackoverflow.com/users/2069064) [ __ ](/feed.xml)
cpp_utility/0eQsx6ip1DwJpli1_278_0.txt
Sign in to forward
cpp_utility/0eQsx6ip1DwJpli1_91_0.txt
The functions being marked as constexpr need to be evaluated on a case-by-case basis and concrete requirements should be set. Common sense rules can go into clause 17 [constexpr.functions], but cases such as the tuple-like get() interface and even forward() and move() need more elaboration.
cpp_utility/CanIconstexpranstdar_21_0.txt
Profile photo for Joe Zbiciak Joe Zbiciak I have been programming since grade schoolUpvoted by Dmitriy Genzel , PhD in CSAuthor has 5.8K answers and 50.2M answer views · 4y Related In C++, can I pass an std::array with an unknown size and type to a function efficiently? Without further context of what you’re trying to ...
cpp_utility/0eQsx6ip1DwJpli1_125_0.txt
You do not have permission to delete messages in this group
cpp_utility/constexprarraysize_103_0.txt
Share [ __ ](https://twitter.com/intent/tweet?text=The+constexpr+array+size+problem - Barry's C%2B%2B Blog&url=https%3A%2F%2Fbrevzin.github.io%2Fc%2B%2B%2F2020%2F02%2F05%2Fconstexpr- array-size%2F "Twitter") [ __ ](https://www.reddit.com/r/cpp/submit?title=The+constexpr+array+size+problem - Barry's C%2B%2B Blog&url=ht...
cpp_utility/cpp_classes_3_1.txt
breakpoint "cpp/utility/breakpoint") (C++26) [ Three-way comparison ](/w/cpp/utility#Three-way_comparison "cpp/utility") [ three_way_comparable three_way_comparable_with ](/w/cpp/utility/compare/three_way_comparable "cpp/utility/compare/three way comparable") (C++20) (C++20) [ strong_ordering ](/w/cpp/utility/...
cpp_utility/constexprarraysize_86_0.txt
bunch_of_spans.emplace_back(c_array); bunch_of_spans.emplace_back(cpp_array); bunch_of_spans.emplace_back(dynamic_span);
cpp_utility/0eQsx6ip1DwJpli1_153_0.txt
to std-dis...@isocpp.org