1 // filesystem tut5.cpp ---------------------------------------------------------------// 2 3 // Copyright Beman Dawes 2010 4 5 // Distributed under the Boost Software License, Version 1.0. 6 // See http://www.boost.org/LICENSE_1_0.txt 7 8 // Library home page: http://www.boost.org/libs/filesystem 9 10 #include <boost/filesystem/fstream.hpp> 11 #include <string> 12 #include <list> 13 namespace fs = boost::filesystem; 14 main()15int main() 16 { 17 // \u263A is "Unicode WHITE SMILING FACE = have a nice day!" 18 std::string narrow_string ("smile2"); 19 std::wstring wide_string (L"smile2\u263A"); 20 std::list<char> narrow_list; 21 narrow_list.push_back('s'); 22 narrow_list.push_back('m'); 23 narrow_list.push_back('i'); 24 narrow_list.push_back('l'); 25 narrow_list.push_back('e'); 26 narrow_list.push_back('3'); 27 std::list<wchar_t> wide_list; 28 wide_list.push_back(L's'); 29 wide_list.push_back(L'm'); 30 wide_list.push_back(L'i'); 31 wide_list.push_back(L'l'); 32 wide_list.push_back(L'e'); 33 wide_list.push_back(L'3'); 34 wide_list.push_back(L'\u263A'); 35 36 { fs::ofstream f("smile"); } 37 { fs::ofstream f(L"smile\u263A"); } 38 { fs::ofstream f(narrow_string); } 39 { fs::ofstream f(wide_string); } 40 { fs::ofstream f(narrow_list); } 41 { fs::ofstream f(wide_list); } 42 narrow_list.pop_back(); 43 narrow_list.push_back('4'); 44 wide_list.pop_back(); 45 wide_list.pop_back(); 46 wide_list.push_back(L'4'); 47 wide_list.push_back(L'\u263A'); 48 { fs::ofstream f(fs::path(narrow_list.begin(), narrow_list.end())); } 49 { fs::ofstream f(fs::path(wide_list.begin(), wide_list.end())); } 50 51 return 0; 52 } 53