Skip to content

Commit

Permalink
Switch to C++11 standard library where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
apolukhin committed Dec 17, 2024
1 parent 7a472c6 commit 665a3a8
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 89 deletions.
1 change: 0 additions & 1 deletion build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ constant boost_dependencies :
/boost/config//boost_config
/boost/core//boost_core
/boost/filesystem//boost_filesystem
/boost/function//boost_function
/boost/predef//boost_predef
/boost/smart_ptr//boost_smart_ptr
/boost/spirit//boost_spirit
Expand Down
8 changes: 0 additions & 8 deletions doc/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,7 @@ local doxygen_params =
\"forcedlinkfs{1}=\\xmlonly<link linkend='boost.dll.fs.\\1'>boost::dll::fs::\\1</link>\\endxmlonly\" \\
\"forcedmacrolink{1}=\\xmlonly<link linkend='\\1'>\\1</link>\\endxmlonly\" "
<doxygen:param>"PREDEFINED= \\
\"BOOST_RV_REF(T)=T&&\" \\
\"BOOST_RV_REF(shared_library)=shared_library&&\" \\
\"BOOST_COPY_ASSIGN_REF(shared_library)=const shared_library&\" \\
\"BOOST_MOVABLE_BUT_NOT_COPYABLE(shared_library)= \\
shared_library(const shared_library&) = delete; \\
shared_library& operator=(const shared_library&) = delete; \" \\
\"BOOST_DLL_IMPORT_RESULT_TYPE=result_type\" \\
\"BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE=result_type\" \\
\"BOOST_EXPLICIT_OPERATOR_BOOL()=explicit operator bool() const noexcept;\" \\
\"BOOST_DLL_DOXYGEN\" "
;

Expand Down
8 changes: 4 additions & 4 deletions include/boost/dll/detail/aggressive_ptr_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace boost { namespace dll { namespace detail {
// This method suppress the warnings and ensures that such casts are safe.
template <class To, class From>
BOOST_FORCEINLINE typename boost::disable_if_c<boost::is_member_pointer<To>::value || boost::is_reference<To>::value || boost::is_member_pointer<From>::value, To>::type
aggressive_ptr_cast(From v) BOOST_NOEXCEPT
aggressive_ptr_cast(From v) noexcept
{
static_assert(
boost::is_pointer<To>::value && boost::is_pointer<From>::value,
Expand Down Expand Up @@ -61,7 +61,7 @@ BOOST_FORCEINLINE typename boost::disable_if_c<boost::is_member_pointer<To>::val

template <class To, class From>
BOOST_FORCEINLINE typename boost::disable_if_c<!boost::is_reference<To>::value || boost::is_member_pointer<From>::value, To>::type
aggressive_ptr_cast(From v) BOOST_NOEXCEPT
aggressive_ptr_cast(From v) noexcept
{
static_assert(
boost::is_pointer<From>::value,
Expand Down Expand Up @@ -90,7 +90,7 @@ BOOST_FORCEINLINE typename boost::disable_if_c<!boost::is_reference<To>::value |

template <class To, class From>
BOOST_FORCEINLINE typename boost::disable_if_c<!boost::is_member_pointer<To>::value || boost::is_member_pointer<From>::value, To>::type
aggressive_ptr_cast(From v) BOOST_NOEXCEPT
aggressive_ptr_cast(From v) noexcept
{
static_assert(
boost::is_pointer<From>::value,
Expand All @@ -109,7 +109,7 @@ BOOST_FORCEINLINE typename boost::disable_if_c<!boost::is_member_pointer<To>::va

template <class To, class From>
BOOST_FORCEINLINE typename boost::disable_if_c<boost::is_member_pointer<To>::value || !boost::is_member_pointer<From>::value, To>::type
aggressive_ptr_cast(From /* v */) BOOST_NOEXCEPT
aggressive_ptr_cast(From /* v */) noexcept
{
static_assert(
boost::is_pointer<To>::value,
Expand Down
2 changes: 1 addition & 1 deletion include/boost/dll/detail/elf_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class elf_info {
read_raw(fs, symbols[0], static_cast<std::size_t>(symtab_size - (symtab_size % sizeof(symbol_t))) );
}

static bool is_visible(const symbol_t& sym) BOOST_NOEXCEPT {
static bool is_visible(const symbol_t& sym) noexcept {
const unsigned char visibility = (sym.st_other & 0x03);
// `(sym.st_info >> 4) != STB_LOCAL_ && !!sym.st_size` check also workarounds the
// GCC's issue https://sourceware.org/bugzilla/show_bug.cgi?id=13621
Expand Down
2 changes: 1 addition & 1 deletion include/boost/dll/detail/pe_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class pe_info {
MSVCR110D.dll
*/
/*
static std::vector<std::string> depend_of(boost::dll::fs::error_code &ec) BOOST_NOEXCEPT {
static std::vector<std::string> depend_of(boost::dll::fs::error_code &ec) noexcept {
std::vector<std::string> ret;
IMAGE_DOS_HEADER* image_dos_header = (IMAGE_DOS_HEADER*)native();
Expand Down
2 changes: 1 addition & 1 deletion include/boost/dll/detail/posix/path_from_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# include <cstddef> // for std::ptrdiff_t

namespace boost { namespace dll { namespace detail {
inline void* strip_handle(void* handle) BOOST_NOEXCEPT {
inline void* strip_handle(void* handle) noexcept {
return reinterpret_cast<void*>(
(reinterpret_cast<std::ptrdiff_t>(handle) >> 2) << 2
);
Expand Down
2 changes: 1 addition & 1 deletion include/boost/dll/detail/system_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace boost { namespace dll { namespace detail {

inline void reset_dlerror() BOOST_NOEXCEPT {
inline void reset_dlerror() noexcept {
#if !BOOST_OS_WINDOWS
const char* const error_txt = dlerror();
(void)error_txt;
Expand Down
2 changes: 1 addition & 1 deletion include/boost/dll/detail/windows/path_from_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace boost { namespace dll { namespace detail {

inline std::error_code last_error_code() BOOST_NOEXCEPT {
inline std::error_code last_error_code() noexcept {
boost::winapi::DWORD_ err = boost::winapi::GetLastError();
return std::error_code(
static_cast<int>(err),
Expand Down
62 changes: 19 additions & 43 deletions include/boost/dll/import.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#include <boost/make_shared.hpp>
#include <boost/dll/shared_library.hpp>

#if defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
# include <boost/function.hpp>
#endif

#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
Expand All @@ -43,12 +39,6 @@ namespace detail {
: f_(lib, func_ptr)
{}

#if defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
operator T*() const noexcept {
return f_.get();
}
#else

// Compilation error at this point means that imported function
// was called with unmatching parameters.
//
Expand All @@ -63,36 +53,22 @@ namespace detail {
{
return (*f_)(static_cast<Args&&>(args)...);
}
#endif
};

template <class T, class = void>
struct import_type;

template <class T>
struct import_type<T, typename boost::disable_if<boost::is_object<T> >::type> {
typedef boost::dll::detail::library_function<T> base_type;

#if defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
typedef boost::function<T> type;
#else
typedef boost::dll::detail::library_function<T> type;
#endif
};

template <class T>
struct import_type<T, typename boost::enable_if<boost::is_object<T> >::type> {
typedef boost::shared_ptr<T> base_type;
typedef boost::shared_ptr<T> type;
};
} // namespace detail


#ifndef BOOST_DLL_DOXYGEN
# define BOOST_DLL_IMPORT_RESULT_TYPE inline typename boost::dll::detail::import_type<T>::type
#endif


/*!
* Returns callable object or boost::shared_ptr<T> that holds the symbol imported
* from the loaded library. Returned value refcounts usage
Expand Down Expand Up @@ -128,42 +104,42 @@ namespace detail {
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
*/
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const boost::dll::fs::path& lib, const char* name,
auto import_symbol(const boost::dll::fs::path& lib, const char* name,
load_mode::type mode = load_mode::default_mode)
{
typedef typename boost::dll::detail::import_type<T>::base_type type;
typedef typename boost::dll::detail::import_type<T>::type type;

boost::shared_ptr<boost::dll::shared_library> p = boost::make_shared<boost::dll::shared_library>(lib, mode);
return type(p, boost::addressof(p->get<T>(name)));
}

//! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const boost::dll::fs::path& lib, const std::string& name,
auto import_symbol(const boost::dll::fs::path& lib, const std::string& name,
load_mode::type mode = load_mode::default_mode)
{
return dll::import_symbol<T>(lib, name.c_str(), mode);
}

//! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const shared_library& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;
auto import_symbol(const shared_library& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::type type;

boost::shared_ptr<boost::dll::shared_library> p = boost::make_shared<boost::dll::shared_library>(lib);
return type(p, boost::addressof(p->get<T>(name)));
}

//! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const shared_library& lib, const std::string& name) {
auto import_symbol(const shared_library& lib, const std::string& name) {
return dll::import_symbol<T>(lib, name.c_str());
}

//! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;
auto import_symbol(shared_library&& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::type type;

boost::shared_ptr<boost::dll::shared_library> p = boost::make_shared<boost::dll::shared_library>(
std::move(lib)
Expand All @@ -173,7 +149,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const char* nam

//! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const std::string& name) {
auto import_symbol(shared_library&& lib, const std::string& name) {
return dll::import_symbol<T>(std::move(lib), name.c_str());
}

Expand Down Expand Up @@ -218,42 +194,42 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const std::stri
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
*/
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::dll::fs::path& lib, const char* name,
auto import_alias(const boost::dll::fs::path& lib, const char* name,
load_mode::type mode = load_mode::default_mode)
{
typedef typename boost::dll::detail::import_type<T>::base_type type;
typedef typename boost::dll::detail::import_type<T>::type type;

boost::shared_ptr<boost::dll::shared_library> p = boost::make_shared<boost::dll::shared_library>(lib, mode);
return type(p, p->get<T*>(name));
}

//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::dll::fs::path& lib, const std::string& name,
auto import_alias(const boost::dll::fs::path& lib, const std::string& name,
load_mode::type mode = load_mode::default_mode)
{
return dll::import_alias<T>(lib, name.c_str(), mode);
}

//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const shared_library& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;
auto import_alias(const shared_library& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::type type;

boost::shared_ptr<boost::dll::shared_library> p = boost::make_shared<boost::dll::shared_library>(lib);
return type(p, p->get<T*>(name));
}

//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const shared_library& lib, const std::string& name) {
auto import_alias(const shared_library& lib, const std::string& name) {
return dll::import_alias<T>(lib, name.c_str());
}

//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(shared_library&& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;
auto import_alias(shared_library&& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::type type;

boost::shared_ptr<boost::dll::shared_library> p = boost::make_shared<boost::dll::shared_library>(
std::move(lib)
Expand All @@ -263,11 +239,11 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(shared_library&& lib, const char* name

//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(shared_library&& lib, const std::string& name) {
auto import_alias(shared_library&& lib, const std::string& name) {
return dll::import_alias<T>(std::move(lib), name.c_str());
}

#undef BOOST_DLL_IMPORT_RESULT_TYPE
#undef auto


}} // boost::dll
Expand Down
2 changes: 1 addition & 1 deletion include/boost/dll/library_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class library_info: private boost::noncopyable {
boost::throw_exception(std::runtime_error("Not native format: 64bit binary"));
}

inline static void throw_if_in_32bit_impl(boost::false_type /* is_32bit_platform */) BOOST_NOEXCEPT {}
inline static void throw_if_in_32bit_impl(boost::false_type /* is_32bit_platform */) noexcept {}


inline static void throw_if_in_32bit() {
Expand Down
14 changes: 7 additions & 7 deletions include/boost/dll/shared_library_load_mode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,37 +207,37 @@ enum type {


/// Free operators for load_mode::type flag manipulation.
BOOST_CONSTEXPR inline type operator|(type left, type right) BOOST_NOEXCEPT {
BOOST_CONSTEXPR inline type operator|(type left, type right) noexcept {
return static_cast<type>(
static_cast<unsigned int>(left) | static_cast<unsigned int>(right)
);
}
BOOST_CXX14_CONSTEXPR inline type& operator|=(type& left, type right) BOOST_NOEXCEPT {
BOOST_CXX14_CONSTEXPR inline type& operator|=(type& left, type right) noexcept {
left = left | right;
return left;
}

BOOST_CONSTEXPR inline type operator&(type left, type right) BOOST_NOEXCEPT {
BOOST_CONSTEXPR inline type operator&(type left, type right) noexcept {
return static_cast<type>(
static_cast<unsigned int>(left) & static_cast<unsigned int>(right)
);
}
BOOST_CXX14_CONSTEXPR inline type& operator&=(type& left, type right) BOOST_NOEXCEPT {
BOOST_CXX14_CONSTEXPR inline type& operator&=(type& left, type right) noexcept {
left = left & right;
return left;
}

BOOST_CONSTEXPR inline type operator^(type left, type right) BOOST_NOEXCEPT {
BOOST_CONSTEXPR inline type operator^(type left, type right) noexcept {
return static_cast<type>(
static_cast<unsigned int>(left) ^ static_cast<unsigned int>(right)
);
}
BOOST_CXX14_CONSTEXPR inline type& operator^=(type& left, type right) BOOST_NOEXCEPT {
BOOST_CXX14_CONSTEXPR inline type& operator^=(type& left, type right) noexcept {
left = left ^ right;
return left;
}

BOOST_CONSTEXPR inline type operator~(type left) BOOST_NOEXCEPT {
BOOST_CONSTEXPR inline type operator~(type left) noexcept {
return static_cast<type>(
~static_cast<unsigned int>(left)
);
Expand Down
Loading

0 comments on commit 665a3a8

Please sign in to comment.