/* * Copyright (c) 2018-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include #include struct A { int a; }; const A& get_a_ref() { static A a; return a; } A get_a() { A a; return a; } int test_a() { static auto x = get_a_ref(); auto y = get_a_ref(); auto copy_y = get_a_ref(); auto z = get_a(); return 0; } auto global_a = get_a_ref(); void test_map() { std::map intMap{{1, 2}, {3, 4}}; for (auto p : intMap) { std::cout << p.first << "->" << p.second << std::endl; } for (auto copy_p : intMap) { std::cout << copy_p.first << "->" << copy_p.second << std::endl; } for (const auto& p : intMap) { std::cout << p.first << "->" << p.second << std::endl; } }