mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
[MSVC] error C2039: "uninitialized_move_n"
This commit is contained in:
parent
9bef0a7b18
commit
1c76f92687
@ -208,11 +208,11 @@
|
|||||||
/// https://stackoverflow.com/questions/6487013/programmatically-determine-whether-exceptions-are-enabled
|
/// https://stackoverflow.com/questions/6487013/programmatically-determine-whether-exceptions-are-enabled
|
||||||
#if defined(__cpp_exceptions) && __cpp_exceptions || \
|
#if defined(__cpp_exceptions) && __cpp_exceptions || \
|
||||||
defined(__EXCEPTIONS) || defined(_CPPUNWIND)
|
defined(__EXCEPTIONS) || defined(_CPPUNWIND)
|
||||||
# define LIBIMP_TRY try
|
# define LIBIMP_TRY try
|
||||||
# define LIBIMP_CATCH(...) catch (__VA_ARGS__)
|
# define LIBIMP_CATCH(...) catch (__VA_ARGS__)
|
||||||
# define LIBIMP_THROW($exception, $ret) throw $exception
|
# define LIBIMP_THROW($exception, ...) throw $exception
|
||||||
#else
|
#else
|
||||||
# define LIBIMP_TRY if (true)
|
# define LIBIMP_TRY if (true)
|
||||||
# define LIBIMP_CATCH(...) else if (false)
|
# define LIBIMP_CATCH(...) else if (false)
|
||||||
# define LIBIMP_THROW($exception, $ret) return $ret
|
# define LIBIMP_THROW($exception, ...) return __VA_ARGS__
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -100,7 +100,7 @@ ForwardIt destroy_n(ForwardIt first, Size n) noexcept {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructs objects by default-initialization
|
* \brief Constructs objects by default-initialization
|
||||||
* in an uninitialized area of memory, defined by a start and a count.
|
* in an uninitialized area of memory, defined by a start and a count.
|
||||||
* \see https://en.cppreference.com/w/cpp/memory/uninitialized_default_construct_n
|
* \see https://en.cppreference.com/w/cpp/memory/uninitialized_default_construct_n
|
||||||
*/
|
*/
|
||||||
template <typename ForwardIt, typename Size>
|
template <typename ForwardIt, typename Size>
|
||||||
@ -121,4 +121,28 @@ ForwardIt uninitialized_default_construct_n(ForwardIt first, Size n) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Moves a number of objects to an uninitialized area of memory.
|
||||||
|
* \see https://en.cppreference.com/w/cpp/memory/uninitialized_move_n
|
||||||
|
*/
|
||||||
|
template <typename InputIt, typename Size, typename NoThrowForwardIt>
|
||||||
|
auto uninitialized_move_n(InputIt first, Size count, NoThrowForwardIt d_first)
|
||||||
|
-> std::pair<InputIt, NoThrowForwardIt> {
|
||||||
|
#if defined(LIBIMP_CPP_17)
|
||||||
|
return std::uninitialized_move_n(first, count, d_first);
|
||||||
|
#else
|
||||||
|
using Value = typename std::iterator_traits<NoThrowForwardIt>::value_type;
|
||||||
|
NoThrowForwardIt current = d_first;
|
||||||
|
LIBIMP_TRY {
|
||||||
|
for (; count > 0; ++first, (void) ++current, --count) {
|
||||||
|
::new (static_cast<void *>(std::addressof(*current))) Value(std::move(*first));
|
||||||
|
}
|
||||||
|
} LIBIMP_CATCH(...) {
|
||||||
|
destroy(d_first, current);
|
||||||
|
LIBIMP_THROW(, {first, d_first});
|
||||||
|
}
|
||||||
|
return {first, current};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
LIBIMP_NAMESPACE_END_
|
LIBIMP_NAMESPACE_END_
|
||||||
|
|||||||
@ -219,7 +219,7 @@ struct holder_type : holder_type_base {
|
|||||||
std::type_info const &type() const noexcept override { return typeid(Value); }
|
std::type_info const &type() const noexcept override { return typeid(Value); }
|
||||||
|
|
||||||
void move(void *s, void *d, std::size_t n) const noexcept override {
|
void move(void *s, void *d, std::size_t n) const noexcept override {
|
||||||
std::uninitialized_move_n(static_cast<Value *>(s), n, static_cast<Value *>(d));
|
::LIBIMP::uninitialized_move_n(static_cast<Value *>(s), n, static_cast<Value *>(d));
|
||||||
}
|
}
|
||||||
void copy(void const *s, void *d, std::size_t n) const noexcept(false) override {
|
void copy(void const *s, void *d, std::size_t n) const noexcept(false) override {
|
||||||
std::uninitialized_copy_n(static_cast<Value const *>(s), n, static_cast<Value *>(d));
|
std::uninitialized_copy_n(static_cast<Value const *>(s), n, static_cast<Value *>(d));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user