From ba687fa2e05cbc3dbfb923a4a2d32b968a435212 Mon Sep 17 00:00:00 2001 From: Beman Date: Sat, 30 Aug 2014 08:43:26 -0400 Subject: [PATCH] The changeover occurs after version 3, so make the #if's relative to 3. --- include/boost/filesystem/detail/version.hpp | 6 +-- include/boost/filesystem/path.hpp | 2 +- include/boost/filesystem/path_traits.hpp | 2 +- src/operations.cpp | 3 ++ test/path_unit_test.cpp | 50 ++++++++++++--------- 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/include/boost/filesystem/detail/version.hpp b/include/boost/filesystem/detail/version.hpp index 8067f87..f5e02f1 100644 --- a/include/boost/filesystem/detail/version.hpp +++ b/include/boost/filesystem/detail/version.hpp @@ -7,9 +7,9 @@ // Library home page: http://www.boost.org/libs/filesystem -// The sole purpose of this header is to define the default version of the library if -// not already defined. +// The sole purpose of this header is to define the default version of the library when +// BOOST_FILESYSTEM_DEFAULT_VERSION has not already been defined. #ifndef BOOST_FILESYSTEM_DEFAULT_VERSION -# define BOOST_FILESYSTEM_DEFAULT_VERSION 4 +# define BOOST_FILESYSTEM_DEFAULT_VERSION 3 #endif diff --git a/include/boost/filesystem/path.hpp b/include/boost/filesystem/path.hpp index 9190bbc..e4fc5f4 100644 --- a/include/boost/filesystem/path.hpp +++ b/include/boost/filesystem/path.hpp @@ -914,7 +914,7 @@ namespace filesystem -#if BOOST_FILESYSTEM_VERSION == 4 +#if BOOST_FILESYSTEM_VERSION > 3 //--------------------------------------------------------------------------------------// // class path detail::append implementation // diff --git a/include/boost/filesystem/path_traits.hpp b/include/boost/filesystem/path_traits.hpp index e1a10b8..25b01fd 100644 --- a/include/boost/filesystem/path_traits.hpp +++ b/include/boost/filesystem/path_traits.hpp @@ -230,7 +230,7 @@ namespace boost { namespace filesystem { const codecvt_type&); } // namespace path_traits -#if BOOST_FILESYSTEM_VERSION == 4 +#if BOOST_FILESYSTEM_VERSION > 3 //--------------------------------------------------------------------------------------// // detail::append helpers // diff --git a/src/operations.cpp b/src/operations.cpp index 262302b..7f0a89d 100644 --- a/src/operations.cpp +++ b/src/operations.cpp @@ -1892,6 +1892,7 @@ namespace path_traits } // namespace path_traits +#if BOOST_FILESYSTEM_VERSION > 3 namespace detail { // do_append() implemented here where directory_entry is a complete type @@ -1901,6 +1902,8 @@ namespace detail no_convert_tag()); } } // namespace detail +#endif + } // namespace filesystem } // namespace boost diff --git a/test/path_unit_test.cpp b/test/path_unit_test.cpp index 855617f..708aefc 100644 --- a/test/path_unit_test.cpp +++ b/test/path_unit_test.cpp @@ -39,7 +39,7 @@ #include // used constructor tests #include -#if BOOST_FILESYSTEM_VERSION == 4 +#if BOOST_FILESYSTEM_VERSION > 3 #include #include #include @@ -149,6 +149,7 @@ namespace std::list wl; // see main() for initialization to w, s, t, r, i, n, g std::vector v; // see main() for initialization to f, u, z std::vector wv; // see main() for initialization to w, f, u, z +#if BOOST_FILESYSTEM_VERSION > 3 boost::string_ref sr(s); boost::wstring_ref wsr(ws); boost::container::string bs("string"); @@ -157,6 +158,8 @@ namespace boost::container::list wbl; // see main() for initialization to w, s, t, r, i, n, g boost::container::vector bv; // see main() for initialization to f, u, z boost::container::vector wbv; // see main() for initialization to w, f, u, z +#endif + class Base {}; class Derived : public Base {}; void fun(const boost::shared_ptr< Base >&) {} @@ -248,52 +251,55 @@ namespace PATH_IS(x10, L"string"); BOOST_TEST_EQ(x10.native().size(), 6U); - path x10a(sr); // boost::string_ref - PATH_IS(x10a, L"string"); - BOOST_TEST_EQ(x10a.native().size(), 6U); - path xll(wl); // std::list PATH_IS(xll, L"wstring"); BOOST_TEST_EQ(xll.native().size(), 7U); - path x11a(wsr); // boost::wstring_ref +#if BOOST_FILESYSTEM_VERSION > 3 + path x10a(sr); // boost::string_ref + PATH_IS(x10a, L"string"); + BOOST_TEST_EQ(x10a.native().size(), 6U); + + path x11a(wsr); // boost::wstring_ref PATH_IS(x11a, L"wstring"); BOOST_TEST_EQ(x11a.native().size(), 7U); - path x12(bs); // boost::string + path x12(bs); // boost::string PATH_IS(x12, L"string"); BOOST_TEST_EQ(x12.native().size(), 6U); - path x13(wbs); // boost::wstring + path x13(wbs); // boost::wstring PATH_IS(x13, L"wstring"); BOOST_TEST_EQ(x13.native().size(), 7U); - path x14(bv); // boost::container::vector + path x14(bv); // boost::container::vector PATH_IS(x14, L"fuz"); BOOST_TEST_EQ(x14.native().size(), 3U); - path x15(wbv); // boost::container::vector + path x15(wbv); // boost::container::vector PATH_IS(x15, L"wfuz"); BOOST_TEST_EQ(x15.native().size(), 4U); +#endif // non-contiguous containers - path x16(l); // std::list + path x16(l); // std::list PATH_IS(x16, L"string"); BOOST_TEST_EQ(x16.native().size(), 6U); - path x17(wl); // std::list + path x17(wl); // std::list PATH_IS(x17, L"wstring"); BOOST_TEST_EQ(x17.native().size(), 7U); - path x18(bl); // std::list +#if BOOST_FILESYSTEM_VERSION > 3 + path x18(bl); // boost::container::list PATH_IS(x18, L"string"); BOOST_TEST_EQ(x18.native().size(), 6U); - path x19(wbl); // std::list + path x19(wbl); // boost::container::list PATH_IS(x19, L"wstring"); BOOST_TEST_EQ(x19.native().size(), 7U); - +#endif // easy-to-make coding errors // path e1(x0, path::codecvt()); // fails to compile, and that is OK @@ -328,21 +334,23 @@ namespace x = string("std::string"); // container char PATH_IS(x, L"std::string"); + + x = wstring(L"std::wstring"); // container wchar_t + PATH_IS(x, L"std::wstring"); +#if BOOST_FILESYSTEM_VERSION > 3 x = boost::container::string("boost::container::string"); PATH_IS(x, L"boost::container::string"); x = boost::string_ref("boost::string_ref"); PATH_IS(x, L"boost::string_ref"); - - x = wstring(L"std::wstring"); // container wchar_t - PATH_IS(x, L"std::wstring"); x = boost::container::wstring(L"boost::container::wstring"); PATH_IS(x, L"boost::container::wstring"); x = boost::wstring_ref(L"boost::wstring_ref"); PATH_IS(x, L"boost::wstring_ref"); +#endif x = "array char"; // array char PATH_IS(x, L"array char"); @@ -822,7 +830,7 @@ namespace void test_codecvt_argument() { -#if BOOST_FILESYSTEM_VERSION == 3 +#if BOOST_FILESYSTEM_VERSION == 3 std::cout << "testing codecvt arguments..." << std::endl; @@ -1146,6 +1154,7 @@ int cpp_main(int, char*[]) wv.push_back(L'u'); wv.push_back(L'z'); +#if BOOST_FILESYSTEM_VERSION > 3 // Boost containers bl.push_back('s'); @@ -1171,7 +1180,8 @@ int cpp_main(int, char*[]) wbv.push_back(L'f'); wbv.push_back(L'u'); wbv.push_back(L'z'); - +#endif + test_overloads(); test_constructors(); test_assignments();