Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorylavic <ylavic.dev@gmail.com>2021-03-29 01:17:24 +0300
committerylavic <ylavic.dev@gmail.com>2021-03-29 12:32:33 +0300
commit08cf9a56c0f3d648ef615c3d5f60d08941ebd3ec (patch)
tree18d04aecf742b2af6987ff042aa2f13925ed6921 /include
parent02f42604bd8d1ca7a65fb981c520d61174ab7585 (diff)
Make StdAllocator C++17-20 compatible.
Diffstat (limited to 'include')
-rw-r--r--include/rapidjson/allocators.h18
-rw-r--r--include/rapidjson/rapidjson.h14
2 files changed, 19 insertions, 13 deletions
diff --git a/include/rapidjson/allocators.h b/include/rapidjson/allocators.h
index 42652142..2871542f 100644
--- a/include/rapidjson/allocators.h
+++ b/include/rapidjson/allocators.h
@@ -20,7 +20,6 @@
#include <memory>
#if RAPIDJSON_HAS_CXX11
-#include <limits>
#include <type_traits>
#endif
@@ -466,6 +465,7 @@ public:
typedef typename traits_type::size_type size_type;
typedef typename traits_type::difference_type difference_type;
+
typedef typename traits_type::value_type value_type;
typedef typename traits_type::pointer pointer;
typedef typename traits_type::const_pointer const_pointer;
@@ -484,19 +484,19 @@ public:
return std::addressof(r);
}
- size_t max_size() const RAPIDJSON_NOEXCEPT
+ size_type max_size() const RAPIDJSON_NOEXCEPT
{
- return std::numeric_limits<size_type>::max() / sizeof(value_type);
+ return traits_type::max_size(*this);
}
template <typename ...Args>
- void construct(pointer p, Args &&...args)
+ void construct(pointer p, Args&&... args)
{
- ::new (static_cast<void*>(p)) value_type(std::forward<Args>(args)...);
+ traits_type::construct(*this, p, std::forward<Args>(args)...);
}
void destroy(pointer p)
{
- p->~T();
+ traits_type::destroy(*this, p);
}
#else // !RAPIDJSON_HAS_CXX11
@@ -513,7 +513,7 @@ public:
return allocator_type::address(r);
}
- size_t max_size() const RAPIDJSON_NOEXCEPT
+ size_type max_size() const RAPIDJSON_NOEXCEPT
{
return allocator_type::max_size();
}
@@ -615,13 +615,13 @@ public:
~StdAllocator() RAPIDJSON_NOEXCEPT
{ }
- typedef typename allocator_type::value_type value_type;
-
template<typename U>
struct rebind {
typedef StdAllocator<U, BaseAllocator> other;
};
+ typedef typename allocator_type::value_type value_type;
+
private:
template <typename, typename>
friend class StdAllocator; // access to StdAllocator<!T>.*
diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h
index 8dcb0a00..10935818 100644
--- a/include/rapidjson/rapidjson.h
+++ b/include/rapidjson/rapidjson.h
@@ -135,6 +135,8 @@
#define RAPIDJSON_CPLUSPLUS __cplusplus
#endif
+//!@endcond
+
///////////////////////////////////////////////////////////////////////////////
// RAPIDJSON_HAS_STDSTRING
@@ -627,10 +629,14 @@ RAPIDJSON_NAMESPACE_END
#if RAPIDJSON_HAS_CXX17
# define RAPIDJSON_DELIBERATE_FALLTHROUGH [[fallthrough]]
-#elif defined(__has_cpp_attribute) && __has_cpp_attribute(fallthrough)
-# define RAPIDJSON_DELIBERATE_FALLTHROUGH __attribute__((fallthrough))
-#elif defined(__has_cpp_attribute) && __has_cpp_attribute(clang::fallthrough)
-# define RAPIDJSON_DELIBERATE_FALLTHROUGH [[clang::fallthrough]]
+#elif defined(__has_cpp_attribute)
+# if __has_cpp_attribute(clang::fallthrough)
+# define RAPIDJSON_DELIBERATE_FALLTHROUGH [[clang::fallthrough]]
+# elif __has_cpp_attribute(fallthrough)
+# define RAPIDJSON_DELIBERATE_FALLTHROUGH __attribute__((fallthrough))
+# else
+# define RAPIDJSON_DELIBERATE_FALLTHROUGH
+# endif
#else
# define RAPIDJSON_DELIBERATE_FALLTHROUGH
#endif