Enable C++17 (#4623)
This commit is contained in:
committed by
Nikolay Krasko
parent
ee9c2f0e33
commit
a362742a37
@@ -6,39 +6,11 @@
|
||||
#ifndef RUNTIME_CPP_SUPPORT_H
|
||||
#define RUNTIME_CPP_SUPPORT_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
// A collection of backported utilities from future C++ versions.
|
||||
|
||||
namespace kotlin {
|
||||
namespace std_support {
|
||||
|
||||
////////////////////////// C++14 //////////////////////////
|
||||
|
||||
template <typename T>
|
||||
using make_unsigned_t = typename std::make_unsigned<T>::type;
|
||||
|
||||
////////////////////////// C++17 //////////////////////////
|
||||
|
||||
template <typename T>
|
||||
constexpr bool is_trivially_destructible_v = std::is_trivially_destructible<T>::value;
|
||||
template <typename T>
|
||||
constexpr bool is_nothrow_default_constructible_v = std::is_nothrow_default_constructible<T>::value;
|
||||
template <typename T>
|
||||
constexpr bool is_nothrow_destructible_v = std::is_nothrow_destructible<T>::value;
|
||||
template <typename T>
|
||||
constexpr bool is_copy_constructible_v = std::is_copy_constructible<T>::value;
|
||||
template <typename T>
|
||||
constexpr bool is_copy_assignable_v = std::is_copy_assignable<T>::value;
|
||||
template <typename T>
|
||||
constexpr bool is_move_constructible_v = std::is_move_constructible<T>::value;
|
||||
template <typename T>
|
||||
constexpr bool is_move_assignable_v = std::is_move_assignable<T>::value;
|
||||
template <typename T>
|
||||
constexpr bool is_nothrow_move_constructible_v = std::is_nothrow_move_constructible<T>::value;
|
||||
template <typename T>
|
||||
constexpr bool is_nothrow_move_assignable_v = std::is_nothrow_move_assignable<T>::value;
|
||||
|
||||
} // namespace std_support
|
||||
} // namespace kotlin
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "CppSupport.hpp"
|
||||
#include "Memory.h"
|
||||
|
||||
// TODO: Generalize for uses outside this file.
|
||||
@@ -38,8 +37,7 @@ class KRefSharedHolder {
|
||||
ForeignRefContext context_;
|
||||
};
|
||||
|
||||
static_assert(
|
||||
kotlin::std_support::is_trivially_destructible_v<KRefSharedHolder>, "KRefSharedHolder destructor is not guaranteed to be called.");
|
||||
static_assert(std::is_trivially_destructible_v<KRefSharedHolder>, "KRefSharedHolder destructor is not guaranteed to be called.");
|
||||
|
||||
class BackRefFromAssociatedObject {
|
||||
public:
|
||||
@@ -68,7 +66,7 @@ class BackRefFromAssociatedObject {
|
||||
};
|
||||
|
||||
static_assert(
|
||||
kotlin::std_support::is_trivially_destructible_v<BackRefFromAssociatedObject>,
|
||||
std::is_trivially_destructible_v<BackRefFromAssociatedObject>,
|
||||
"BackRefFromAssociatedObject destructor is not guaranteed to be called.");
|
||||
|
||||
#endif // RUNTIME_MEMORYSHAREDREFS_HPP
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
#include "CppSupport.hpp"
|
||||
#include "KAssert.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Memory.h"
|
||||
@@ -51,7 +50,7 @@ OBJ_GETTER0(Kotlin_native_internal_undefined) {
|
||||
}
|
||||
|
||||
void* Kotlin_interop_malloc(KLong size, KInt align) {
|
||||
if (size < 0 || static_cast<kotlin::std_support::make_unsigned_t<decltype(size)>>(size) > std::numeric_limits<size_t>::max()) {
|
||||
if (size < 0 || static_cast<std::make_unsigned_t<decltype(size)>>(size) > std::numeric_limits<size_t>::max()) {
|
||||
return nullptr;
|
||||
}
|
||||
RuntimeAssert(align > 0, "Unsupported alignment");
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#ifndef RUNTIME_UTILS_H
|
||||
#define RUNTIME_UTILS_H
|
||||
|
||||
#include "CppSupport.hpp"
|
||||
|
||||
namespace kotlin {
|
||||
|
||||
// A helper for implementing classes with disabled copy constructor and copy assignment.
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
#include "Utils.hpp"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include <type_traits>
|
||||
|
||||
#include "CppSupport.hpp"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace kotlin;
|
||||
|
||||
@@ -30,21 +30,21 @@ public:
|
||||
} // namespace
|
||||
|
||||
TEST(UtilsTest, MoveOnlyImpl) {
|
||||
static_assert(std_support::is_nothrow_default_constructible_v<MoveOnlyImpl>, "Must be nothrow default constructible");
|
||||
static_assert(std_support::is_nothrow_destructible_v<MoveOnlyImpl>, "Must be nothrow destructible");
|
||||
static_assert(!std_support::is_copy_constructible_v<MoveOnlyImpl>, "Must not be copy constructible");
|
||||
static_assert(!std_support::is_copy_assignable_v<MoveOnlyImpl>, "Must not be copy assignable");
|
||||
static_assert(std_support::is_nothrow_move_constructible_v<MoveOnlyImpl>, "Must be nothrow move constructible");
|
||||
static_assert(std_support::is_nothrow_move_assignable_v<MoveOnlyImpl>, "Must be nothrow move assignable");
|
||||
static_assert(std::is_nothrow_default_constructible_v<MoveOnlyImpl>, "Must be nothrow default constructible");
|
||||
static_assert(std::is_nothrow_destructible_v<MoveOnlyImpl>, "Must be nothrow destructible");
|
||||
static_assert(!std::is_copy_constructible_v<MoveOnlyImpl>, "Must not be copy constructible");
|
||||
static_assert(!std::is_copy_assignable_v<MoveOnlyImpl>, "Must not be copy assignable");
|
||||
static_assert(std::is_nothrow_move_constructible_v<MoveOnlyImpl>, "Must be nothrow move constructible");
|
||||
static_assert(std::is_nothrow_move_assignable_v<MoveOnlyImpl>, "Must be nothrow move assignable");
|
||||
static_assert(sizeof(MoveOnlyImpl) == sizeof(A), "Must not increase size");
|
||||
}
|
||||
|
||||
TEST(UtilsTest, PinnedImpl) {
|
||||
static_assert(std_support::is_nothrow_default_constructible_v<PinnedImpl>, "Must be nothrow default constructible");
|
||||
static_assert(std_support::is_nothrow_destructible_v<PinnedImpl>, "Must be nothrow destructible");
|
||||
static_assert(!std_support::is_copy_constructible_v<PinnedImpl>, "Must not be copy constructible");
|
||||
static_assert(!std_support::is_copy_assignable_v<PinnedImpl>, "Must not be copy assignable");
|
||||
static_assert(!std_support::is_move_constructible_v<PinnedImpl>, "Must not be move constructible");
|
||||
static_assert(!std_support::is_move_assignable_v<PinnedImpl>, "Must not be move assignable");
|
||||
static_assert(std::is_nothrow_default_constructible_v<PinnedImpl>, "Must be nothrow default constructible");
|
||||
static_assert(std::is_nothrow_destructible_v<PinnedImpl>, "Must be nothrow destructible");
|
||||
static_assert(!std::is_copy_constructible_v<PinnedImpl>, "Must not be copy constructible");
|
||||
static_assert(!std::is_copy_assignable_v<PinnedImpl>, "Must not be copy assignable");
|
||||
static_assert(!std::is_move_constructible_v<PinnedImpl>, "Must not be move constructible");
|
||||
static_assert(!std::is_move_assignable_v<PinnedImpl>, "Must not be move assignable");
|
||||
static_assert(sizeof(PinnedImpl) == sizeof(A), "Must not increase size");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user