Category : std

For instance, #include <algorithm> #include <iostream> #include <numeric> #include <vector> int main() { std::vector<int> empty{}; std::reverse(empty.begin(), empty.end()); std::cout << "Sum: " << std::accumulate(empty.cbegin(), empty.cend(), 0) << std::endl; std::cout << empty.size(); } builds and runs as I expect: sum: 0 size: 0 Can I be guaranteed this behavior will happen on any standard-compliant compiler? Source: Windows ..

Read more

i have written the following code. The std::size() function ist executing properly in the main() function but not in the getMin() function. Why? #include <iostream> int getMin(int numbers[]) { int temp = numbers[0]; int sizeA = std::size(numbers); for (int i = 1; i < sizeA; i++) { if (temp > numbers[i]) temp = numbers[i]; } ..

Read more

i have written the following code. The std::size() function ist executing properly in the main() function but not in the getMin() function. Why? #include <iostream> int getMin(int numbers[]) { int temp = numbers[0]; int sizeA = std::size(numbers); for (int i = 1; i < sizeA; i++) { if (temp > numbers[i]) temp = numbers[i]; } ..

Read more

In Learncpp.com I found that c++1x is the code name of c++11. And When I noticed Code::blocks IDE compiler flags, I saw that it uses the c++0x as coming C++ language standard of C++ 11. Then I noticed that Code::blocks have both -std=c++11 and -std=c++0x compiler flags in compiler flags option. If -std=c++11 and -std=c++0x ..

Read more

Here is my implmentation of vector class, please have a look #include<bits/stdc++.h> using namespace std; template <class T> class my_vec { private: T* vec; unsigned int size; public: my_vec() { size = 0; vec = 0; cout << "default ctor called" << endl; } ~my_vec() { delete[] vec; cout << "dtor called" << endl; } ..

Read more