1+ // clang-format off
12/* ****************************************************************/ /* *
23 * \file learn_move.cpp
34 * \brief Move semantics in C++
1213 * \author Xuhua Huang
1314 * \date October 2021
1415 *********************************************************************/
16+ // clang-format on
1517
1618#include < iostream>
1719#include < stdlib.h>
1820#include < string>
1921#include < vector>
2022
21- #include " ../Util/print_vec.hpp"
2223#include " ../Util/is_instance_of.hpp"
24+ #include " ../Util/print_vec.hpp"
2325
2426int main (void )
2527{
@@ -30,9 +32,9 @@ int main(void)
3032 std::vector<std::string> str_vec;
3133 str_vec.push_back (hello_str);
3234
33- // uses the rvalue reference push_back(T&&) overload,
35+ // uses the rvalue reference push_back(T&&) overload,
3436 // which means no strings will be copied; instead, the contents
35- // of world_str will be moved into the vector.
37+ // of world_str will be moved into the vector.
3638 // This is less expensive, but also means world_str might now be empty.
3739 str_vec.push_back (std::move (world_str));
3840 // still able to access hello_str, but not world_str
@@ -44,11 +46,12 @@ int main(void)
4446 std::cout << " \n End of the vector" << " \n " ;
4547
4648 std::cout << " Attempting to access hello_str: " << hello_str << " \n "
47- << " Attempting to access world_str: " << world_str << " \n " ;
49+ << " Attempting to access world_str: " << world_str << " \n " ;
4850
4951 /* Test functions in the ../Util headers. */
5052 std::cout << " Testing Util functions: " << " \n " ;
51- if (util::type::is_instance_of<std::vector<std::string>>(str_vec)) {
53+ if (util::type::is_instance_of<std::vector<std::string>>(str_vec))
54+ {
5255 util::vector::print_vec (str_vec);
5356 }
5457
0 commit comments