id stringlengths 16 145 | text stringlengths 1 179k | title stringclasses 1
value |
|---|---|---|
cpp_utility/76362_118_0.txt | No milestone | |
cpp_utility/76362_36_0.txt | Cancel Create saved search | |
cpp_utility/0eQsx6ip1DwJpli1_120_0.txt | Reply to author | |
cpp_utility/76362_65_0.txt | edited | |
cpp_utility/76362_50_0.txt | Already on GitHub? [ Sign in ](/login?return_to=%2Fllvm%2Fllvm-
project%2Fissues%2Fnew%2Fchoose) to your account | |
cpp_utility/cpp_classes_2_5.txt | _tuple_size&action=edit)
[ tuple_cat ](/w/cpp/utility/tuple/tuple_cat "cpp/utility/tuple/tuple cat") (C++11) | creates a ` tuple ` by concatenating any number of tuples
(function template) [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/utility/tuple/dsc_tuple_cat&action=edit)
Re... | |
cpp_utility/0eQsx6ip1DwJpli1_180_0.txt | It is also useful as a statement of intent: by marking a function as
constexpr, you request that a compiler issues a diagnostic if it can easily
see that a call to that function can never appear in a constant expression.
There is a limited set of cases in which such a diagnostic is mandatory, and
in the other cases it'... | |
cpp_utility/0eQsx6ip1DwJpli1_53_0.txt | Sign in to reply to author | |
cpp_utility/0eQsx6ip1DwJpli1_69_0.txt | This means that this makes it now somewhat harder to test it in the
wild (Of-course it will still be possible to define some "extended
mode" where this would be supported). | |
cpp_utility/76362_37_0.txt | [ Sign in ](/login?return_to=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-
project%2Fissues%2F76362) | |
cpp_utility/0eQsx6ip1DwJpli1_63_0.txt | to std-dis...@isocpp.org | |
cpp_utility/0eQsx6ip1DwJpli1_202_0.txt | unread, | |
cpp_utility/76362_63_0.txt | ### | |
cpp_utility/76362_8_0.txt | * [ All features ](https://github.com/features)
* [ Documentation ](https://docs.github.com)
* [ GitHub Skills ](https://skills.github.com)
* [ Blog ](https://github.blog) | |
cpp_utility/constexprarraysize_25_0.txt | template <typename T, size_t N>
constexpr size_t array_size(T (*)[N]) {
return N;
} | |
cpp_utility/constexprarraysize_72_0.txt | And if we do still do bounds checking in the latter case, is there actually a
line we can draw for which things we do on the left-hand-side (like this
bounds-check) but which things we don’t (like actually require that `
*ptrs_to_arrays[3] ` is a constant expression itself)? | |
cpp_utility/0eQsx6ip1DwJpli1_104_0.txt | Report message | |
cpp_utility/constexprarraysize_109_0.txt | Trending Tags | |
cpp_utility/0eQsx6ip1DwJpli1_187_0.txt | Forward | |
cpp_utility/76362_54_0.txt | [ dyumin ](/dyumin) opened this issue Dec 25, 2023 · 3 comments | |
cpp_utility/0eQsx6ip1DwJpli1_87_0.txt | On 10/12/13 11:05 PM, Daniel Kr�gler wrote:
> 2013/10/12 < [ thomas....@gmail.com ]() >:
>> Hello,
>> I'm playing around with the relaxed constraints on constexpr functions with
>> clang + libc++ trunk and noticed something strange with std::array :
Because
>> std::array lacks a constexpr "reference operator[]" (23.3.2... | |
cpp_utility/0eQsx6ip1DwJpli1_33_0.txt | Hello,
I'm playing around with the relaxed constraints on constexpr functions with
clang + libc++ trunk and noticed something strange with std::array : Because
std::array lacks a constexpr "reference operator[]" (23.3.2.1.3), it is
impossible to instantiate an std::array in a constepxr function and write in
it. So it l... | |
cpp_utility/CanIconstexpranstdar_20_0.txt | The intent of any constexpr, is doing work at compile time though the power of template programming, if I understand correctly. A lot of programs don’t need to worry about performance, but in some cases in some programs, constexpr may be able to improve cri | |
cpp_utility/0eQsx6ip1DwJpli1_287_0.txt |
Le samedi 12 octobre 2013 16:43:09 UTC+2, [ thomas....@gmail.com ]() a écrit : | |
cpp_utility/0eQsx6ip1DwJpli1_74_0.txt | Oct 13, 2013, 3:01:05 PM 10/13/13 | |
cpp_utility/cpp_tag_1_3.txt | iant") (C++17) | a type-safe discriminated union
(class template) [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/utility/dsc_variant&action=edit)
[ any ](/w/cpp/utility/any "cpp/utility/any") (C++17) | objects that hold instances of any [ CopyConstructible ](/w/cpp/named_req/CopyC... | |
cpp_utility/0eQsx6ip1DwJpli1_6_0.txt | [ ](https://www.google.com.hk/intl/en/about/products?tab=gh) | |
cpp_utility/0eQsx6ip1DwJpli1_232_0.txt | Forward | |
cpp_utility/CanIconstexpranstdar_3_0.txt | Promoted by Masterworks
Profile photo for Lila Fisher
Lila Fisher
Art Education | @Masterworks
·
1y
Did Harry inherit more than William?
Yes and no. When the Queen mother died back in 2002 she left more money to Harry, knowing that William would eventually become Prince and inherit the Duchy of Cornwall, a private esta... | |
cpp_utility/constexprarraysize_94_0.txt | But I would love to get to the point where this code actually compiles: | |
cpp_utility/0eQsx6ip1DwJpli1_29_0.txt | Sign in to report message | |
cpp_utility/0eQsx6ip1DwJpli1_230_0.txt | Reply to author | |
cpp_utility/0eQsx6ip1DwJpli1_80_0.txt | You do not have permission to delete messages in this group | |
cpp_utility/0eQsx6ip1DwJpli1_292_0.txt | Reply to author | |
cpp_utility/0eQsx6ip1DwJpli1_12_0.txt | [ About ](./a/isocpp.org/g/std-discussion/about) | |
cpp_utility/cpp_tag_2_4.txt | nctional/default_searcher
"cpp/utility/functional/default searcher") (C++17)
[ boyer_moore_searcher ](/w/cpp/utility/functional/boyer_moore_searcher
"cpp/utility/functional/boyer moore searcher") (C++17)
[ boyer_moore_horspool_searcher
](/w/cpp/utility/functional/boyer_moore_horspool_searcher
"cpp/utility/function... | |
cpp_utility/CanIconstexpranstdar_19_0.txt | I don’t doubt there are some handy uses for this sort of thing. But I have not had access to C++20 yet, so have not had time to work with it. | |
cpp_utility/CanIconstexpranstdar_38_0.txt | “This is the key to healthy aging,” says Norris. “I’m living pro | |
cpp_utility/constexprarraysize_51_0.txt | template <typename T, size_t Extent>
struct span {
template <range R>
span(R&& r)
requires (std::size(r) == Extent);
}; | |
cpp_utility/CanIconstexpranstdar_16_0.txt | constexpr std::vector myConstArray { 1, 2, 3}; | |
cpp_utility/constexprarraysize_53_0.txt | ### Is there a library solution for this? __ | |
cpp_utility/constexprarraysize_70_0.txt | A different, less generous, way to describe a feature like this would be to
say that ` x.f() ` can still be a constant expression even if ` x ` is a
reference to unknown object, as long as ` f ` is a static member function and
` x ` is a sufficiently direct naming of the reference (for some as-yet
defined definition of... | |
cpp_utility/0eQsx6ip1DwJpli1_132_0.txt | On 10/13/13 4:55 PM, Gabriel Dos Reis wrote:
> David Krauss < [ pot...@gmail.com ]() > writes:
>
> [...]
>
> | TBH I don't really understand why we need the constexpr qualifier for
> | functions in the first place.
>
> I am not sure what you mean by this: (1) that you are unaware of how the
> constexpr keyword came to ... | |
cpp_utility/0eQsx6ip1DwJpli1_205_0.txt | Sign in to reply to author | |
cpp_utility/0eQsx6ip1DwJpli1_254_0.txt | Sign in to reply to author | |
cpp_utility/76362_103_0.txt | Author | |
cpp_utility/0eQsx6ip1DwJpli1_207_0.txt | Sign in to forward | |
cpp_utility/CanIconstexpranstdar_14_0.txt | Profile photo for Assistant
Assistant
Bot
·
Nov 28
Yes, you can use the constexpr keyword to declare an std::array in C++. This allows you to create a compile-time constant array. However, there are some limitations on what you can initialize a constexpr array with, so you'll need to ensure that the initialization valu... | |
cpp_utility/0eQsx6ip1DwJpli1_100_0.txt | Sign in to forward | |
cpp_utility/constexprarraysize_40_0.txt |
It’s not a complex type. | |
cpp_utility/0eQsx6ip1DwJpli1_150_0.txt | Sign in to report message | |
cpp_utility/0eQsx6ip1DwJpli1_272_0.txt | ### thomas....@gmail.com | |
cpp_utility/constexprarraysize_29_0.txt | Notably, the rule we’re violating is only about _references_ . We can’t write
a function that takes an array by value, so let’s use the next-best thing: `
std::array ` and use the standard library’s ` std::size ` ( [ cppref
](https://en.cppreference.com/w/cpp/iterator/size) ): | |
cpp_utility/0eQsx6ip1DwJpli1_243_0.txt | > On Mon, Oct 14, 2013 at 12:06 AM, Daryle Walker < dar...@gmail.com >
> wrote:
>
> | |
cpp_utility/cpp_classes_2_2.txt | nst") (C++17)
Common 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/ut... | |
cpp_utility/0eQsx6ip1DwJpli1_45_0.txt |
template < int ... x >
constexpr auto compile_time_sort_ ()
{
auto seq = std :: integer_sequence < int , x ...>();
auto idx = std :: make_integer_sequence < int , sizeof ...( x )>(); | |
cpp_utility/0eQsx6ip1DwJpli1_196_0.txt | to std-dis...@isocpp.org, thomas....@gmail.com | |
cpp_utility/0eQsx6ip1DwJpli1_52_0.txt | Reply to author | |
cpp_utility/0eQsx6ip1DwJpli1_136_0.txt | Making the function qualifier optional would only be a breaking change
for code relying on its absence to prevent constantness. Is that a
deal-breaker? | |
cpp_utility/constexprarraysize_96_0.txt | std::vector<std::span<int, 5>> bunch_of_spans;
bunch_of_spans.emplace_back(dynamic_span); | |
cpp_utility/76362_80_0.txt | Author | |
cpp_utility/0eQsx6ip1DwJpli1_86_0.txt | to std-dis...@isocpp.org | |
cpp_utility/0eQsx6ip1DwJpli1_31_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/constexprarraysize_44_0.txt | std::vector<int> v3 = {1, 2, 3};
f(v3); // ill-formed
f(std::span<int, 5>(v3)); // compiles but UB | |
cpp_utility/0eQsx6ip1DwJpli1_197_0.txt | Actually, it's worse than you think. I originally used N3690 as a C++14
reference for my proposal (a future N3794), then I discovered there's a later
draft: N3691. That draft stripped "constexpr" off of all of array 's
methods, except for size , empty , and max_size . So my proposal
followed the later draft. | |
cpp_utility/0eQsx6ip1DwJpli1_77_0.txt | Forward | |
cpp_utility/constexprarraysize_0_0.txt | [  ](/) | |
cpp_utility/0eQsx6ip1DwJpli1_116_0.txt |  | |
cpp_utility/0eQsx6ip1DwJpli1_90_0.txt | TBH I don't really understand why we need the constexpr qualifier for
functions in the first place. The compiler can never guarantee that any
constexpr qualifier is doing anything useful. It all comes down to use
of the function at the call site. With the newly relaxed rules for C++14
it's particularly ridiculous. See
... | |
cpp_utility/constexprarraysize_71_0.txt | * ` (*ptr_to_array)->size() ` ?
* ` (*ptrs_to_arrays[3])->size() ` ? What about if ` ptrs_to_arrays ` was actually an array of only 2 arrays, at which point we’d surely want to reject this during constant evaluation in the same way we reject out-of-bounds access generally? | |
cpp_utility/0eQsx6ip1DwJpli1_103_0.txt | Copy link | |
cpp_utility/constexprarraysize_14_0.txt | Let’s say I have an array, and I want to get its size and use it as a constant
expression. In C, we would write a macro for this: | |
cpp_utility/0eQsx6ip1DwJpli1_247_0.txt | I think N3690 had all methods marked constexpr , even the non- const ones.
(That's newly allowed for C++14.) Importantly, it had the iterator and data
methods constexpr . (I'm no longer sure since I trashed my copy of N3690
since getting N3691.) | |
cpp_utility/0eQsx6ip1DwJpli1_43_0.txt | template < int ... x , int ... idx >
constexpr auto compile_time_sort_imp ( std :: integer_sequence < int ,
x ...>,
std :: integer_sequence < int , idx ...>)
{
constexpr int N = sizeof ...( x );
int a [] = { x ...};
for ( int i = 0 ; i < N - 1 ; i ++)
{
// sort the array... | |
cpp_utility/0eQsx6ip1DwJpli1_121_0.txt | Sign in to reply to author | |
cpp_utility/0eQsx6ip1DwJpli1_159_0.txt | ### Richard Smith | |
cpp_utility/cpp_classes_0_2.txt | 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/utility/variant") (C++17)
| [ tuple_size ](/w/cpp/utility/tuple_size "cpp/utility/tuple size") (C++11)
---
[ tupl... | |
cpp_utility/0eQsx6ip1DwJpli1_157_0.txt | \-- Gaby | |
cpp_utility/0eQsx6ip1DwJpli1_155_0.txt | | On 10/13/13 4:55 PM, Gabriel Dos Reis wrote:
| > David Krauss < [ pot...@gmail.com ]() > writes:
| >
| > [...]
| >
| > | TBH I don't really understand why we need the constexpr qualifier for
| > | functions in the first place.
| >
| > I am not sure what you mean by this: (1) that you are unaware of how the
| > conste... | |
cpp_utility/constexprarraysize_59_0.txt |
This works for both C arrays (the first overload) and ` std::array ` (the
second). A similar approach was proposed in [ P1419 ](https://wg21.link/p1419)
, the only difference was that the proposal spelled this approach `
static_extent_v<std::remove_cvref_t<R>> ` instead of `
type_size(type<std::remove_cvref_t<R>>) ` . | |
cpp_utility/76362_28_0.txt | We read every piece of feedback, and take your input very seriously. | |
cpp_utility/0eQsx6ip1DwJpli1_96_0.txt | Oct 13, 2013, 4:55:34 PM 10/13/13 | |
cpp_utility/constexprarraysize_91_0.txt | template <typename Arg>
void emplace_back(Arg&& arg) {
push_back(std::span<int, 5>(std::forward<Arg>(Arg));
} | |
cpp_utility/76362_21_0.txt | * [ Pricing ](https://github.com/pricing) | |
cpp_utility/0eQsx6ip1DwJpli1_286_0.txt | to std-dis...@isocpp.org, thomas....@gmail.com | |
cpp_utility/0eQsx6ip1DwJpli1_270_0.txt | Both N3690 and N3691 have constexpr applied on all const member of std::array
but none on non-const member. | |
cpp_utility/0eQsx6ip1DwJpli1_195_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_233_0.txt | Sign in to forward | |
cpp_utility/0eQsx6ip1DwJpli1_85_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_298_0.txt | Google apps | |
cpp_utility/76362_60_0.txt | ## Comments | |
cpp_utility/0eQsx6ip1DwJpli1_218_0.txt | N3691 is supposed to be identical to N3690, other than the cover sheet. If
it's not, that's unintended, and you should let the project editor know.
(N3690 is the Committee Draft, N3691 is the Working Draft). In this instance,
I don't see what you're referring to: in both documents, page 764 contains a
constexpr operato... | |
cpp_utility/constexprarraysize_27_0.txt |
This case _has_ to be ill-formed, copying a function parameter during constant
evaluation means it has to itself be a constant expression, and function
parameters are not constant expressions - even in ` constexpr ` or ` consteval
` functions. | |
cpp_utility/76362_30_0.txt | Cancel Submit feedback | |
cpp_utility/constexprarraysize_73_0.txt | Moreover, even if we go this direction. Let’s say that we come up with some
kind of exception in this space, such that the original code we tried to write
actually works. Just reproducing the relevant code for proximity: | |
cpp_utility/0eQsx6ip1DwJpli1_95_0.txt | unread, | |
cpp_utility/CanIconstexpranstdar_49_0.txt | Related questions
Why can't std::map be constexpr?
How do I use the C++20 constexpr std::vector?
Is std::vector faster than std::array?
Why is there std::array<> in C++11? What are the benefits of it?
When should one use std::array instead std::vector? What does std::array offer that std::vector lacks?
Why are so many ... | |
cpp_utility/0eQsx6ip1DwJpli1_172_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/cpp_tag_2_3.txt | inus")
[ negate ](/w/cpp/utility/functional/negate "cpp/utility/functional/negate")
[ multiplies ](/w/cpp/utility/functional/multiplies
"cpp/utility/functional/multiplies")
[ divides ](/w/cpp/utility/functional/divides
"cpp/utility/functional/divides")
[ modulus ](/w/cpp/utility/functional/modulus
"cpp/util... | |
cpp_utility/0eQsx6ip1DwJpli1_189_0.txt | Delete |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.