inline boost::filesystem into std::filesystem

This commit is contained in:
qPCR4vir 2019-11-05 19:29:30 +01:00
parent babcdb477d
commit 597f6c05cd

View File

@ -9,7 +9,7 @@
* *
* @file nana/filesystem/filesystem.hpp * @file nana/filesystem/filesystem.hpp
* @author Ariel Vina-Rodriguez, Jinhao * @author Ariel Vina-Rodriguez, Jinhao
* @brief Mimic std::experimental::filesystem::v1 (boost v3) * @brief Mimic std::filesystem
* and need VC2015 or a C++11 compiler. With a few correction can be compiler by VC2013 * and need VC2015 or a C++11 compiler. With a few correction can be compiler by VC2013
*/ */
@ -34,12 +34,6 @@
//Filesystem Selection //Filesystem Selection
#include <nana/config.hpp> #include <nana/config.hpp>
#if defined(NANA_USING_NANA_FILESYSTEM) || defined(NANA_USING_STD_FILESYSTEM) || defined(NANA_USING_BOOST_FILESYSTEM)
#undef NANA_USING_NANA_FILESYSTEM
#undef NANA_USING_STD_FILESYSTEM
#undef NANA_USING_BOOST_FILESYSTEM
#endif
#define NANA_USING_NANA_FILESYSTEM 0 #define NANA_USING_NANA_FILESYSTEM 0
#define NANA_USING_STD_FILESYSTEM 0 #define NANA_USING_STD_FILESYSTEM 0
#define NANA_USING_BOOST_FILESYSTEM 0 #define NANA_USING_BOOST_FILESYSTEM 0
@ -50,16 +44,15 @@
#define NANA_USING_NANA_FILESYSTEM 1 #define NANA_USING_NANA_FILESYSTEM 1
#elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) )) #elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) ))
#undef NANA_USING_BOOST_FILESYSTEM #undef NANA_USING_BOOST_FILESYSTEM
#define NANA_USING_BOOST_FILESYSTEM 1 #define NANA_USING_BOOST_FILESYSTEM 1
# include <chrono> # include <chrono>
# include <boost/filesystem.hpp> # include <boost/filesystem.hpp>
// add boost::filesystem into std::experimental::filesystem // inline boost::filesystem into std::filesystem
namespace std { namespace std {
namespace experimental {
namespace filesystem { namespace filesystem {
inline namespace boost_filesystem {
using namespace boost::filesystem; using namespace boost::filesystem;
using file_time_type = std::chrono::time_point<std::chrono::system_clock>; using file_time_type = std::chrono::time_point<std::chrono::system_clock>;
@ -84,7 +77,7 @@ namespace std {
// 1.55.0 NOT enable directory_iterator C++11 range-base for // 1.55.0 NOT enable directory_iterator C++11 range-base for
// http://www.boost.org/doc/libs/1_54_0/boost/filesystem/operations.hpp // http://www.boost.org/doc/libs/1_54_0/boost/filesystem/operations.hpp
#if BOOST_VERSION < 105600 #if BOOST_VERSION < 105600
namespace boost namespace boost { // todo ??
// enable directory_iterator C++11 range-base for statement use --------------------// // enable directory_iterator C++11 range-base for statement use --------------------//
// begin() and end() are only used by a range-based for statement in the context of // begin() and end() are only used by a range-based for statement in the context of
@ -99,19 +92,10 @@ namespace std {
{ {
return directory_iterator(); return directory_iterator();
} }
#endif
} // filesystem
} // experimental
namespace filesystem
{
using namespace experimental::filesystem;
} }
#ifndef __cpp_lib_experimental_filesystem
# define __cpp_lib_experimental_filesystem 201406
#endif #endif
} // boost_filesystem
} // filesystem
} // std } // std
#else #else