Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Copy double[2][3] into vector<vector<double>>
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86 #include <cstddef> #include <algorithm> #include <iostream> #include <iterator> #include <vector> #define DIMENSION(array) (sizeof(array) / sizeof(array[0])) int main() { double arr[2][3] = {{33, 55, 77}, {2, 8, 5}}; std::vector<std::vector<double>> vec(DIMENSION(arr)); for (std::size_t i = 0; i < DIMENSION(arr); ++i) { vec[i].reserve(DIMENSION(arr[i])); // optional vec[i].assign(std::cbegin(arr[i]), std::cend(arr[i])); } std::ostream_iterator<double> cout_iter(std::cout, " "); for (const auto& v : vec) { std::copy(std::cbegin(v), std::cend(v), cout_iter); std::cout << '\n'; } }
run
|
edit
|
history
|
help
0
asock
#22.2
c++
Cross-platform multithreading minimal example (g++ and cl.exe)
What is the fastest/most efficient way to find the highest set bit (msb) in an integer in C?
jkljklj
Struct packing
Fast sine to fill array (sin/cos pair)
Compile time creation of class member stl container (const std::array) filled with elements.
WinAPI not accessible