Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
Filter by
Sorted by
Tagged with
Filter by Employee ID
Score of 1
0 answers
220 views

Under https://eel.is/c++draft/intro.object#16 (see below) does the creation of a std::array of std::byte or unsigned char implicitly create objects? Except during constant evaluation, an operation ...
Score of 0
0 answers
271 views

While debugging something I stumbled into this behavior on godbolt. When compiling and running the following (godbolt link https://godbolt.org/z/9c5966sbK): #include <array> int main() { ...
Score of 15
4 answers
1256 views

Unlike C array, std::array is allowed to have zero length. But the current implementations differ in how std::array<T,0> is implemented, in particular the sizes of the object are different. This ...
Score of 1
2 answers
232 views

I have the below code. What am I doing wrong that I can't simple assign the array myBar to the 1st index of foo? Using memcpy works but somehow I don't want to use this approach. #include <array>...
Score of 12
7 answers
2004 views

I am developing a C++17 framework that has optional third-party dependencies and I'd like to construct an std::array that contains the names of the available dependencies. The CMake file sets ...
Score of 4
1 answer
196 views

The following code compiles successfully with clang and gcc. Naively, I would have expected a2 to have type std::array<std::array<int, 1>, 1>. #include <array> auto a1 = std::array{...
Score of 0
2 answers
185 views

This code builds successfully with Clang 20.1.10 and with GCC 15.1, but not with Microsoft Visual C++ 2022 version 17.14.0: #include <array> #include <string> int main() { static ...
Score of 7
1 answer
262 views

The elements in the array are not default constructible therefore we need to initialize the array directly from elements in std::vector. #include <array> #include <vector> class foo { ...
Score of 9
0 answers
331 views

Initially I thought that std::to_array would be equivalent to initializing directly, i.e. a way to avoid having to specify the length of the array in the code, compare: constexpr auto arr = std::...
Score of 2
1 answer
818 views

I would like to have this code with std::vector replaced with std::array, but I presume it can not be done since std::array is not a container std::ranges::to understands. constexpr auto dice = std::...
Score of 41
1 answer
2644 views

The following code snippet implicitly converts a std::array to a std::tuple: std::array<int,3> arr = {2,4,6}; std::tuple<int,int,int> tup; tup = arr; // c++23 or later The assignment ...
Score of 1
4 answers
273 views

I need to access an std::array<double, 9> x by two functions, namely funA and funB. funA only needs the first 6 entries of x and funB the last 3 entries. I am limited to C++14. I know there are ...
Score of 2
0 answers
63 views

We know std::array<double, N> Can be initialized to all-zero by std::array<double, N> my_array {} My question is if I have std::array<std::array<double, N>, M> my_array {} ...
Score of 15
3 answers
953 views

The following is a toy example The class student has a std::array<char, 15> called name and an integer age. A student has a member function called encode that calls a global template function ...
Score of 3
2 answers
156 views

I am using an API that expects a contiguous block of memory that contains pointers. the pointers themselves can be nullptr. Currently, I use C-Arrays: ID3D11ShaderResourceView* srvs[] = { ...
user avatar

15 30 50 per page
1
2 3 4 5
32