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
accessing private of different type of template
ㅇㅇ
MSVC ignoring unknown attributes
Copy elision sample modern C++
c++ pure apstraction
Strings
Hangman
CommandQueue
cross-platform sleep function
For NULL-embedded strings, CStringT::Find() produces what you may not expect