config.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Copyright Antony Polukhin, 2018-2025.
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /// \file boost/dll/config.hpp
  7. /// \brief Imports filesystem, error_code, errc, system_error, make_error_code from Boost or C++17 into `boost::dll::fs` namespace.
  8. #ifndef BOOST_DLL_DETAIL_CONFIG_HPP
  9. #define BOOST_DLL_DETAIL_CONFIG_HPP
  10. #include <boost/config.hpp>
  11. #ifdef BOOST_HAS_PRAGMA_ONCE
  12. # pragma once
  13. #endif
  14. #ifdef BOOST_DLL_DOXYGEN
  15. /// Define this macro to make Boost.DLL use C++17's std::filesystem::path and std::system_error.
  16. #define BOOST_DLL_USE_STD_FS BOOST_DLL_USE_STD_FS
  17. /// Define this macro to make Boost.DLL use boost::shared_ptr instead of std::shared_ptr. This macro will be removed
  18. /// after a few releases, consider migrating to std::shared_ptr.
  19. #define BOOST_DLL_USE_BOOST_SHARED_PTR BOOST_DLL_USE_BOOST_SHARED_PTR
  20. /// This namespace contains aliases to the Boost or C++17 classes. Aliases are configured using BOOST_DLL_USE_STD_FS macro.
  21. namespace boost { namespace dll { namespace fs {
  22. /// Alias to `std::filesystem::path` if \forcedmacrolink{BOOST_DLL_USE_STD_FS} is defined by user.
  23. /// Alias to `boost::filesystem::path` otherwise.
  24. using path = std::conditional_t<BOOST_DLL_USE_STD_FS, std::filesystem::path, boost::filesystem::path>;
  25. /// Alias to `std::error_code` if \forcedmacrolink{BOOST_DLL_USE_STD_FS} is defined by user.
  26. /// boost::system::error_code otherwise.
  27. using error_code = std::conditional_t<BOOST_DLL_USE_STD_FS, std::error_code, boost::system::error_code>;
  28. /// Alias to `std::system_error` if \forcedmacrolink{BOOST_DLL_USE_STD_FS} is defined by user.
  29. /// Alias to `boost::system::system_error` otherwise.
  30. using system_error = std::conditional_t<BOOST_DLL_USE_STD_FS, std::system_error, boost::system::system_error>;
  31. }}}
  32. #endif
  33. #ifdef BOOST_DLL_USE_STD_FS
  34. #include <filesystem>
  35. #include <system_error>
  36. namespace boost { namespace dll { namespace fs {
  37. using namespace std::filesystem;
  38. using std::error_code;
  39. using std::system_error;
  40. }}}
  41. #else // BOOST_DLL_USE_STD_FS
  42. #include <boost/filesystem/path.hpp>
  43. #include <boost/filesystem/operations.hpp>
  44. #include <boost/system/system_error.hpp>
  45. #include <boost/system/error_code.hpp>
  46. namespace boost { namespace dll { namespace fs {
  47. using namespace boost::filesystem;
  48. using boost::system::error_code;
  49. using boost::system::system_error;
  50. }}}
  51. #endif // BOOST_DLL_USE_STD_FS
  52. #ifdef BOOST_DLL_USE_BOOST_SHARED_PTR
  53. #include <boost/make_shared.hpp>
  54. namespace boost { namespace dll { namespace detail {
  55. template <class T>
  56. using shared_ptr = boost::shared_ptr<T>;
  57. using boost::make_shared;
  58. }}}
  59. #else // BOOST_DLL_USE_STD_FS
  60. #include <memory>
  61. namespace boost { namespace dll { namespace detail {
  62. template <class T>
  63. using shared_ptr = std::shared_ptr<T>;
  64. using std::make_shared;
  65. }}}
  66. #endif // BOOST_DLL_USE_STD_FS
  67. #endif // BOOST_DLL_DETAIL_PUSH_OPTIONS_HPP