Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <functional>
- #include <map>
- #include <string>
- class A
- {
- public:
- A(): i_(10) {}
- ~A() {}
- void set(int i) { i_ = i; }
- int get_i() const { return i_; }
- private:
- int i_;
- };
- int main(int argc, char** argv)
- {
- std::map<std::string, std::reference_wrapper<const A>> map;
- A a;
- map.emplace(std::make_pair(std::string("a"), std::ref<const A>(a)));
- auto a1 = map.at("a").get();
- a1.set(11);
- std::cout << a1.get_i() << " " << a.get_i() << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement