Created
November 1, 2018 13:23
-
-
Save yoya/acd8ac29c4e86a618c2a41be03350acb to your computer and use it in GitHub Desktop.
iterator_test.cpp (NG)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g++ -std=c++11 iterator_test.cpp | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
class my_vector { | |
public: | |
std::vector<int> m_vec; | |
my_vector(int len, int value) { | |
std::vector<int> v(len, value); | |
m_vec = std::move(v); | |
} | |
std::vector<int>::const_iterator begin() const { return m_vec.begin(); } | |
std::vector<int>::const_iterator end() const { return m_vec.end(); } | |
}; | |
int main(void) { | |
const my_vector v(10, 255); | |
std::transform(v.begin(), v.end(), v.begin(), | |
[](float val) { return val/10; }); | |
for (int n : v.m_vec) { | |
std::cout << n << ' '; | |
} | |
return 0; | |
} |
Author
yoya
commented
Nov 1, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment