Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
iterator by value, by reference
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <iostream> #include <map> struct A { A() {} A(const A& a) { std::cout << "copy ctor" << std::endl; } A& operator=(const A& other) { std::cout << "copy assignment" << std::endl; return *this; } }; int main() { A a1, a2; a1 = a2; std::cout << "Hello, world!\n"; std::map<int, A> m; m.insert({1, A{}}); m.insert({2, A{}}); m.insert({3, A{}}); std::cout << "iterating..." << std::endl; for(auto e : m) { std::cout << e.first << "," << &e.second << std::endl; } std::cout << "iterating 2..." << std::endl; for(const auto& e : m) { std::cout << e.first << "," << &e.second << std::endl; } }
run
|
edit
|
history
|
help
0
infix to postfix v 1.0
why fatal error C1083
LinkedList
Printf %px test
upper_bound With binary_function Visual Studio 2008 Bug?
bool behaviour (convertion/promotion) for logical and artihmetic operators
Overload resolve function pointer
Templatized Visitor Pattern Example
Multiple inheritance of empty classes - sizeof
bitfields_msvc