mirror of
https://github.com/isar/libmdbx.git
synced 2025-04-01 02:32:57 +08:00
mdbx++: явное определение external-инстанцирования mdbx::buffer<>
c API-атрибутами (backport).
This commit is contained in:
parent
3282adf8bd
commit
52a19fecca
23
mdbx.h++
23
mdbx.h++
@ -107,6 +107,16 @@
|
|||||||
#include <span>
|
#include <span>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_MSC_VER) || defined(__clang__)
|
||||||
|
/* adequate compilers */
|
||||||
|
#define MDBX_EXTERN_API_TEMPLATE(API_ATTRIBUTES, API_TYPENAME) extern template class API_ATTRIBUTES API_TYPENAME
|
||||||
|
#define MDBX_INSTALL_API_TEMPLATE(API_ATTRIBUTES, API_TYPENAME) template class API_TYPENAME
|
||||||
|
#else
|
||||||
|
/* stupid microsoft showing off */
|
||||||
|
#define MDBX_EXTERN_API_TEMPLATE(API_ATTRIBUTES, API_TYPENAME) extern template class API_TYPENAME
|
||||||
|
#define MDBX_INSTALL_API_TEMPLATE(API_ATTRIBUTES, API_TYPENAME) template class API_ATTRIBUTES API_TYPENAME
|
||||||
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <ratio>
|
#include <ratio>
|
||||||
@ -1500,8 +1510,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class txn;
|
friend class txn;
|
||||||
struct silo;
|
using swap_alloc = allocation_aware_details::swap_alloc<struct silo, allocator_type>;
|
||||||
using swap_alloc = allocation_aware_details::swap_alloc<silo, allocator_type>;
|
|
||||||
struct silo /* Empty Base Class Optimization */ : public allocator_type {
|
struct silo /* Empty Base Class Optimization */ : public allocator_type {
|
||||||
MDBX_CXX20_CONSTEXPR const allocator_type &get_allocator() const noexcept { return *this; }
|
MDBX_CXX20_CONSTEXPR const allocator_type &get_allocator() const noexcept { return *this; }
|
||||||
MDBX_CXX20_CONSTEXPR allocator_type &get_allocator() noexcept { return *this; }
|
MDBX_CXX20_CONSTEXPR allocator_type &get_allocator() noexcept { return *this; }
|
||||||
@ -2729,6 +2738,12 @@ inline string<ALLOCATOR> make_string(const PRODUCER &producer, const ALLOCATOR &
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MDBX_EXTERN_API_TEMPLATE(LIBMDBX_API_TYPE, buffer<legacy_allocator>);
|
||||||
|
|
||||||
|
#if defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L && _GLIBCXX_USE_CXX11_ABI
|
||||||
|
MDBX_EXTERN_API_TEMPLATE(LIBMDBX_API_TYPE, buffer<polymorphic_allocator>);
|
||||||
|
#endif /* __cpp_lib_memory_resource >= 201603L */
|
||||||
|
|
||||||
/// \brief Combines data slice with boolean flag to represent result of certain
|
/// \brief Combines data slice with boolean flag to represent result of certain
|
||||||
/// operations.
|
/// operations.
|
||||||
struct value_result {
|
struct value_result {
|
||||||
@ -2854,9 +2869,13 @@ template <typename ALLOCATOR, typename CAPACITY_POLICY> struct buffer_pair_spec
|
|||||||
operator pair() const noexcept { return pair(key, value); }
|
operator pair() const noexcept { return pair(key, value); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// \brief Combines pair of buffers for key and value to hold an operands for certain operations.
|
||||||
template <typename BUFFER>
|
template <typename BUFFER>
|
||||||
using buffer_pair = buffer_pair_spec<typename BUFFER::allocator_type, typename BUFFER::reservation_policy>;
|
using buffer_pair = buffer_pair_spec<typename BUFFER::allocator_type, typename BUFFER::reservation_policy>;
|
||||||
|
|
||||||
|
/// \brief Default pair of buffers.
|
||||||
|
using default_buffer_pair = buffer_pair<default_buffer>;
|
||||||
|
|
||||||
/// end of cxx_data @}
|
/// end of cxx_data @}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
24
src/mdbx.c++
24
src/mdbx.c++
@ -1162,12 +1162,32 @@ bool from_base64::is_erroneous() const noexcept {
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
template class LIBMDBX_API_TYPE buffer<legacy_allocator>;
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning(push)
|
||||||
|
/* warning C4251: 'mdbx::buffer<...>::silo_':
|
||||||
|
* struct 'mdbx::buffer<..>::silo' needs to have dll-interface to be used by clients of class 'mdbx::buffer<...>'
|
||||||
|
*
|
||||||
|
* Microsoft не хочет признавать ошибки и пересматривать приятные решения, поэтому MSVC продолжает кошмарить
|
||||||
|
* и стращать разработчиков предупреждениями, тем самым перекладывая ответственность на их плечи.
|
||||||
|
*
|
||||||
|
* В данном случае предупреждение выдаётся из-за инстанцирования std::string::allocator_type::pointer и
|
||||||
|
* std::pmr::string::allocator_type::pointer внутри mdbx::buffer<..>::silo. А так как эти типы являются частью
|
||||||
|
* стандартной библиотеки C++ они всегда будут доступны и без необходимости их инстанцирования и экспорта из libmdbx.
|
||||||
|
*
|
||||||
|
* Поэтому нет других вариантов как заглушить это предупреждение и еще раз плюнуть в сторону microsoft. */
|
||||||
|
#pragma warning(disable : 4251)
|
||||||
|
#endif /* MSVC */
|
||||||
|
|
||||||
|
MDBX_INSTALL_API_TEMPLATE(LIBMDBX_API_TYPE, buffer<legacy_allocator>);
|
||||||
|
|
||||||
#if defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L && _GLIBCXX_USE_CXX11_ABI
|
#if defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L && _GLIBCXX_USE_CXX11_ABI
|
||||||
template class LIBMDBX_API_TYPE buffer<polymorphic_allocator>;
|
MDBX_INSTALL_API_TEMPLATE(LIBMDBX_API_TYPE, buffer<polymorphic_allocator>);
|
||||||
#endif /* __cpp_lib_memory_resource >= 201603L */
|
#endif /* __cpp_lib_memory_resource >= 201603L */
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif /* MSVC */
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
static inline MDBX_env_flags_t mode2flags(env::mode mode) {
|
static inline MDBX_env_flags_t mode2flags(env::mode mode) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user