Squashed 'deps/oxlib/' changes from 170d6e35a..a787fef61
a787fef61 Uncomment code that from Pico fix 298184d58 Fix build warning 51999199c [ox] Fix build problems on Raspberry Pi Pico 682fc5b85 Merge commit 'c286e3794d9d4cc571671548ad765ce370bcfcb4' 94209fd74 [ox/std] Make is_integral use raw types git-subtree-dir: deps/oxlib git-subtree-split: a787fef6147dcd11519c24f992289349f0ec355d
This commit is contained in:
@@ -38,17 +38,6 @@ const std::map<ox::StringView, std::function<ox::Error(ox::StringView)>> tests =
|
|||||||
auto a1 = buffer->malloc(sizeof(String)).value;
|
auto a1 = buffer->malloc(sizeof(String)).value;
|
||||||
auto a2 = buffer->malloc(sizeof(String)).value;
|
auto a2 = buffer->malloc(sizeof(String)).value;
|
||||||
oxAssert(a1.valid(), "Allocation 1 failed.");
|
oxAssert(a1.valid(), "Allocation 1 failed.");
|
||||||
oxAssert(a2.valid(), "Allocation 2 failed.");
|
|
||||||
auto s1Buff = buffer->dataOf<String>(a1);
|
|
||||||
auto s2Buff = buffer->dataOf<String>(a2);
|
|
||||||
oxAssert(s1Buff.valid(), "s1 allocation 1 failed.");
|
|
||||||
oxAssert(s2Buff.valid(), "s2 allocation 2 failed.");
|
|
||||||
auto &s1 = *new (s1Buff) String("asdf");
|
|
||||||
auto &s2 = *new (s2Buff) String("aoeu");
|
|
||||||
oxTrace("test") << "s1: " << s1.c_str();
|
|
||||||
oxTrace("test") << "s2: " << s2.c_str();
|
|
||||||
oxAssert(s1 == "asdf", "Allocation 1 not as expected.");
|
|
||||||
oxAssert(s2 == "aoeu", "Allocation 2 not as expected.");
|
|
||||||
oxAssert(buffer->free(a1), "Free failed.");
|
oxAssert(buffer->free(a1), "Free failed.");
|
||||||
oxAssert(buffer->free(a2), "Free failed.");
|
oxAssert(buffer->free(a2), "Free failed.");
|
||||||
oxAssert(buffer->setSize(buffer->size() - buffer->available()), "Resize failed.");
|
oxAssert(buffer->setSize(buffer->size() - buffer->available()), "Resize failed.");
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef OX_USE_STDLIB
|
#include <ox/std/defines.hpp>
|
||||||
|
|
||||||
|
#ifndef OX_OS_BareMetal
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|||||||
@@ -44,15 +44,7 @@ class MetalClawWriter: public ModelHandlerBase<MetalClawWriter<Writer>, OpType::
|
|||||||
|
|
||||||
constexpr ~MetalClawWriter() noexcept = default;
|
constexpr ~MetalClawWriter() noexcept = default;
|
||||||
|
|
||||||
constexpr Error field(CString, int8_t const *val) noexcept;
|
constexpr Error field(CString, Integer_c auto const *val) noexcept;
|
||||||
constexpr Error field(CString, int16_t const *val) noexcept;
|
|
||||||
constexpr Error field(CString, int32_t const *val) noexcept;
|
|
||||||
constexpr Error field(CString, int64_t const *val) noexcept;
|
|
||||||
|
|
||||||
constexpr Error field(CString, uint8_t const *val) noexcept;
|
|
||||||
constexpr Error field(CString, uint16_t const *val) noexcept;
|
|
||||||
constexpr Error field(CString, uint32_t const *val) noexcept;
|
|
||||||
constexpr Error field(CString, uint64_t const *val) noexcept;
|
|
||||||
|
|
||||||
constexpr Error field(CString, bool const *val) noexcept;
|
constexpr Error field(CString, bool const *val) noexcept;
|
||||||
|
|
||||||
@@ -133,42 +125,7 @@ constexpr MetalClawWriter<Writer>::MetalClawWriter(Writer &writer, Optional<int>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Writer_c Writer>
|
template<Writer_c Writer>
|
||||||
constexpr Error MetalClawWriter<Writer>::field(CString, int8_t const *val) noexcept {
|
constexpr Error MetalClawWriter<Writer>::field(CString, Integer_c auto const *val) noexcept {
|
||||||
return appendInteger(*val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<Writer_c Writer>
|
|
||||||
constexpr Error MetalClawWriter<Writer>::field(CString, int16_t const *val) noexcept {
|
|
||||||
return appendInteger(*val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<Writer_c Writer>
|
|
||||||
constexpr Error MetalClawWriter<Writer>::field(CString, int32_t const *val) noexcept {
|
|
||||||
return appendInteger(*val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<Writer_c Writer>
|
|
||||||
constexpr Error MetalClawWriter<Writer>::field(CString, int64_t const *val) noexcept {
|
|
||||||
return appendInteger(*val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<Writer_c Writer>
|
|
||||||
constexpr Error MetalClawWriter<Writer>::field(CString, uint8_t const *val) noexcept {
|
|
||||||
return appendInteger(*val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<Writer_c Writer>
|
|
||||||
constexpr Error MetalClawWriter<Writer>::field(CString, uint16_t const *val) noexcept {
|
|
||||||
return appendInteger(*val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<Writer_c Writer>
|
|
||||||
constexpr Error MetalClawWriter<Writer>::field(CString, uint32_t const *val) noexcept {
|
|
||||||
return appendInteger(*val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<Writer_c Writer>
|
|
||||||
constexpr Error MetalClawWriter<Writer>::field(CString, uint64_t const *val) noexcept {
|
|
||||||
return appendInteger(*val);
|
return appendInteger(*val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,14 +43,14 @@ struct TestStruct {
|
|||||||
int32_t Int6 = 0;
|
int32_t Int6 = 0;
|
||||||
int32_t Int7 = 0;
|
int32_t Int7 = 0;
|
||||||
int32_t Int8 = 0;
|
int32_t Int8 = 0;
|
||||||
int unionIdx = 1;
|
int32_t unionIdx = 1;
|
||||||
TestUnion Union;
|
TestUnion Union;
|
||||||
ox::String String;
|
ox::String String;
|
||||||
ox::IString<32> IString = "";
|
ox::IString<32> IString = "";
|
||||||
uint32_t List[4] = {0, 0, 0, 0};
|
uint32_t List[4] = {0, 0, 0, 0};
|
||||||
ox::Vector<uint32_t> Vector = {1, 2, 3, 4, 5};
|
ox::Vector<uint32_t> Vector = {1, 2, 3, 4, 5};
|
||||||
ox::Vector<uint32_t> Vector2 = {1, 2, 3, 4, 5};
|
ox::Vector<uint32_t> Vector2 = {1, 2, 3, 4, 5};
|
||||||
ox::HashMap<ox::String, int> Map;
|
ox::HashMap<ox::String, int32_t> Map;
|
||||||
TestStructNest EmptyStruct;
|
TestStructNest EmptyStruct;
|
||||||
TestStructNest Struct;
|
TestStructNest Struct;
|
||||||
constexpr ~TestStruct() noexcept {
|
constexpr ~TestStruct() noexcept {
|
||||||
@@ -204,7 +204,8 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
|||||||
std::cout << "val.length: " << val.length << '\n';
|
std::cout << "val.length: " << val.length << '\n';
|
||||||
return ox::Error(1);
|
return ox::Error(1);
|
||||||
}
|
}
|
||||||
ox::LittleEndian<decltype(expected)> decoded = *reinterpret_cast<decltype(expected)*>(&val.data[1]);
|
ox::LittleEndian<decltype(expected)> decoded;
|
||||||
|
ox::memcpy(&decoded, &val.data[1], sizeof(decoded));
|
||||||
if (expected != decoded) {
|
if (expected != decoded) {
|
||||||
std::cout << "decoded: " << decoded << ", expected: " << expected << '\n';
|
std::cout << "decoded: " << decoded << ", expected: " << expected << '\n';
|
||||||
return ox::Error(1);
|
return ox::Error(1);
|
||||||
@@ -370,7 +371,7 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
|||||||
const auto [type, typeErr] = ox::buildTypeDef(typeStore, testIn);
|
const auto [type, typeErr] = ox::buildTypeDef(typeStore, testIn);
|
||||||
oxAssert(typeErr, "Descriptor write failed");
|
oxAssert(typeErr, "Descriptor write failed");
|
||||||
ox::BufferReader br({dataBuff, dataBuffLen});
|
ox::BufferReader br({dataBuff, dataBuffLen});
|
||||||
OX_RETURN_ERROR(ox::walkModel<ox::MetalClawReader>(type, br,
|
return ox::walkModel<ox::MetalClawReader>(type, br,
|
||||||
[](const ox::Vector<ox::FieldName>&, const ox::Vector<ox::String>&, const ox::DescriptorField &f, ox::MetalClawReader *rdr) -> ox::Error {
|
[](const ox::Vector<ox::FieldName>&, const ox::Vector<ox::String>&, const ox::DescriptorField &f, ox::MetalClawReader *rdr) -> ox::Error {
|
||||||
//std::cout << f.fieldName.c_str() << '\n';
|
//std::cout << f.fieldName.c_str() << '\n';
|
||||||
auto fieldName = f.fieldName.c_str();
|
auto fieldName = f.fieldName.c_str();
|
||||||
@@ -455,8 +456,7 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
|||||||
}
|
}
|
||||||
return ox::Error(0);
|
return ox::Error(0);
|
||||||
}
|
}
|
||||||
));
|
);
|
||||||
return ox::Error(0);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,22 +126,7 @@ class TypeDescWriter {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr const DescriptorType *type(const int8_t *val) const noexcept;
|
constexpr const DescriptorType *type(const Integer_c auto *val) const noexcept;
|
||||||
[[nodiscard]]
|
|
||||||
constexpr const DescriptorType *type(const int16_t *val) const noexcept;
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr const DescriptorType *type(const int32_t *val) const noexcept;
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr const DescriptorType *type(const int64_t *val) const noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr const DescriptorType *type(const uint8_t *val) const noexcept;
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr const DescriptorType *type(const uint16_t *val) const noexcept;
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr const DescriptorType *type(const uint32_t *val) const noexcept;
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr const DescriptorType *type(const uint64_t *val) const noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr const DescriptorType *type(const bool *val) const noexcept;
|
constexpr const DescriptorType *type(const bool *val) const noexcept;
|
||||||
@@ -295,52 +280,26 @@ constexpr const DescriptorType *TypeDescWriter::type(UnionView<U> val) const noe
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const DescriptorType *TypeDescWriter::type(const int8_t*) const noexcept {
|
constexpr const DescriptorType *TypeDescWriter::type(Integer_c auto const *val) const noexcept {
|
||||||
constexpr auto PT = PrimitiveType::SignedInteger;
|
constexpr auto isSigned = ox::is_signed_v<decltype(*val)>;
|
||||||
constexpr auto Bytes = 1;
|
constexpr auto PT = isSigned ?
|
||||||
return getType(types::Int8, 0, PT, Bytes);
|
PrimitiveType::SignedInteger :
|
||||||
|
PrimitiveType::UnsignedInteger;
|
||||||
|
constexpr auto sz = sizeof(*val);
|
||||||
|
constexpr auto bytes = sizeof(*val);
|
||||||
|
return getType([] {
|
||||||
|
switch (sz) {
|
||||||
|
case 1:
|
||||||
|
return isSigned ? types::Int8 : types::Uint8;
|
||||||
|
case 2:
|
||||||
|
return isSigned ? types::Int16 : types::Uint16;
|
||||||
|
case 4:
|
||||||
|
return isSigned ? types::Int32 : types::Uint32;
|
||||||
|
case 8:
|
||||||
|
return isSigned ? types::Int64 : types::Uint64;
|
||||||
}
|
}
|
||||||
|
return types::Int32;
|
||||||
constexpr const DescriptorType *TypeDescWriter::type(const int16_t*) const noexcept {
|
}(), 0, PT, bytes);
|
||||||
constexpr auto PT = PrimitiveType::SignedInteger;
|
|
||||||
constexpr auto Bytes = 2;
|
|
||||||
return getType(types::Int16, 0, PT, Bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const DescriptorType *TypeDescWriter::type(const int32_t*) const noexcept {
|
|
||||||
constexpr auto PT = PrimitiveType::SignedInteger;
|
|
||||||
constexpr auto Bytes = 4;
|
|
||||||
return getType(types::Int32, 0, PT, Bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const DescriptorType *TypeDescWriter::type(const int64_t*) const noexcept {
|
|
||||||
constexpr auto PT = PrimitiveType::SignedInteger;
|
|
||||||
constexpr auto Bytes = 8;
|
|
||||||
return getType(types::Int64, 0, PT, Bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const DescriptorType *TypeDescWriter::type(const uint8_t*) const noexcept {
|
|
||||||
constexpr auto PT = PrimitiveType::UnsignedInteger;
|
|
||||||
constexpr auto Bytes = 1;
|
|
||||||
return getType(types::Uint8, 0, PT, Bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const DescriptorType *TypeDescWriter::type(const uint16_t*) const noexcept {
|
|
||||||
constexpr auto PT = PrimitiveType::UnsignedInteger;
|
|
||||||
constexpr auto Bytes = 2;
|
|
||||||
return getType(types::Uint16, 0, PT, Bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const DescriptorType *TypeDescWriter::type(const uint32_t*) const noexcept {
|
|
||||||
constexpr auto PT = PrimitiveType::UnsignedInteger;
|
|
||||||
constexpr auto Bytes = 4;
|
|
||||||
return getType(types::Uint32, 0, PT, Bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const DescriptorType *TypeDescWriter::type(const uint64_t*) const noexcept {
|
|
||||||
constexpr auto PT = PrimitiveType::UnsignedInteger;
|
|
||||||
constexpr auto Bytes = 8;
|
|
||||||
return getType(types::Uint64, 0, PT, Bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const DescriptorType *TypeDescWriter::type(const bool*) const noexcept {
|
constexpr const DescriptorType *TypeDescWriter::type(const bool*) const noexcept {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class OrganicClawWriter {
|
|||||||
|
|
||||||
Error field(CString const key, int32_t const *val) noexcept {
|
Error field(CString const key, int32_t const *val) noexcept {
|
||||||
if (targetValid() && (*val || m_json.isArray())) {
|
if (targetValid() && (*val || m_json.isArray())) {
|
||||||
value(key) = *val;
|
value(key) = static_cast<Json::Int>(*val);
|
||||||
}
|
}
|
||||||
++m_fieldIt;
|
++m_fieldIt;
|
||||||
return {};
|
return {};
|
||||||
@@ -92,7 +92,7 @@ class OrganicClawWriter {
|
|||||||
|
|
||||||
Error field(CString const key, uint32_t const *val) noexcept {
|
Error field(CString const key, uint32_t const *val) noexcept {
|
||||||
if (targetValid() && (*val || m_json.isArray())) {
|
if (targetValid() && (*val || m_json.isArray())) {
|
||||||
value(key) = *val;
|
value(key) = static_cast<Json::UInt>(*val);
|
||||||
}
|
}
|
||||||
++m_fieldIt;
|
++m_fieldIt;
|
||||||
return {};
|
return {};
|
||||||
@@ -221,9 +221,9 @@ Error OrganicClawWriter::field(CString key, T const *val) noexcept {
|
|||||||
// the int type needs to be normalized because jsoncpp doesn't
|
// the int type needs to be normalized because jsoncpp doesn't
|
||||||
// factor in every permutation unsigned long, etc.
|
// factor in every permutation unsigned long, etc.
|
||||||
if constexpr(is_signed_v<T>) {
|
if constexpr(is_signed_v<T>) {
|
||||||
value(key) = static_cast<Int<8 * sizeof(*val)>>(*val);
|
value(key) = static_cast<Json::Int64>(*val);
|
||||||
} else {
|
} else {
|
||||||
value(key) = static_cast<Uint<8 * sizeof(*val)>>(*val);
|
value(key) = static_cast<Json::UInt64>(*val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if constexpr(isVector_v<T> || isArray_v<T>) {
|
} else if constexpr(isVector_v<T> || isArray_v<T>) {
|
||||||
|
|||||||
@@ -78,10 +78,10 @@ target_compile_definitions(
|
|||||||
$<$<BOOL:${OX_NODEBUG}>:OX_NODEBUG>
|
$<$<BOOL:${OX_NODEBUG}>:OX_NODEBUG>
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32 AND NOT OX_BARE_METAL)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
OxStd PUBLIC
|
OxStd PUBLIC
|
||||||
$<$<CXX_COMPILER_ID:GNU>:$<$<BOOL:${OX_USE_STDLIB}>:dl>>
|
dl
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ constexpr void oxAssert(const ox::Error&, const char*) noexcept {}
|
|||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define ox_alloca(size) _alloca(size)
|
#define ox_alloca(size) _alloca(size)
|
||||||
#elif OX_USE_STDLIB
|
#elif OX_USE_STDLIB
|
||||||
|
#include <alloca.h>
|
||||||
#define ox_alloca(size) alloca(size)
|
#define ox_alloca(size) alloca(size)
|
||||||
#else
|
#else
|
||||||
#define ox_alloca(size) __builtin_alloca(size)
|
#define ox_alloca(size) __builtin_alloca(size)
|
||||||
|
|||||||
@@ -103,29 +103,30 @@ constexpr bool is_const_v<const T> = true;
|
|||||||
// is_integral /////////////////////////////////////////////////////////////////
|
// is_integral /////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename T> struct is_integral: false_type {};
|
template<typename T> struct is_integral: false_type {};
|
||||||
template<> struct is_integral<bool> : true_type {};
|
|
||||||
template<> struct is_integral<wchar_t> : true_type {};
|
|
||||||
template<> struct is_integral<int8_t> : true_type {};
|
|
||||||
template<> struct is_integral<uint8_t> : true_type {};
|
|
||||||
template<> struct is_integral<int16_t> : true_type {};
|
|
||||||
template<> struct is_integral<uint16_t>: true_type {};
|
|
||||||
template<> struct is_integral<int32_t> : true_type {};
|
|
||||||
template<> struct is_integral<uint32_t>: true_type {};
|
|
||||||
template<> struct is_integral<const bool> : true_type {};
|
|
||||||
template<> struct is_integral<const wchar_t> : true_type {};
|
|
||||||
template<> struct is_integral<const int8_t> : true_type {};
|
|
||||||
template<> struct is_integral<const uint8_t> : true_type {};
|
|
||||||
template<> struct is_integral<const int16_t> : true_type {};
|
|
||||||
template<> struct is_integral<const uint16_t>: true_type {};
|
|
||||||
template<> struct is_integral<const int32_t> : true_type {};
|
|
||||||
template<> struct is_integral<const uint32_t>: true_type {};
|
|
||||||
|
|
||||||
// some of these need to be done with the actual language syntax because no one
|
// some of these need to be done with the actual language syntax because no one
|
||||||
// can agree on what an (u)int64_t is...
|
// can agree on what an (u)int64_t is...
|
||||||
|
template<> struct is_integral<bool> : true_type {};
|
||||||
|
template<> struct is_integral<wchar_t> : true_type {};
|
||||||
|
template<> struct is_integral<signed char> : true_type {};
|
||||||
|
template<> struct is_integral<unsigned char> : true_type {};
|
||||||
|
template<> struct is_integral<short> : true_type {};
|
||||||
|
template<> struct is_integral<unsigned short> : true_type {};
|
||||||
|
template<> struct is_integral<int> : true_type {};
|
||||||
|
template<> struct is_integral<unsigned int> : true_type {};
|
||||||
template<> struct is_integral<long> : true_type {};
|
template<> struct is_integral<long> : true_type {};
|
||||||
template<> struct is_integral<long long> : true_type {};
|
template<> struct is_integral<long long> : true_type {};
|
||||||
template<> struct is_integral<unsigned long> : true_type {};
|
template<> struct is_integral<unsigned long> : true_type {};
|
||||||
template<> struct is_integral<unsigned long long> : true_type {};
|
template<> struct is_integral<unsigned long long> : true_type {};
|
||||||
|
|
||||||
|
template<> struct is_integral<const bool> : true_type {};
|
||||||
|
template<> struct is_integral<const wchar_t> : true_type {};
|
||||||
|
template<> struct is_integral<const signed char> : true_type {};
|
||||||
|
template<> struct is_integral<const unsigned char> : true_type {};
|
||||||
|
template<> struct is_integral<const short> : true_type {};
|
||||||
|
template<> struct is_integral<const unsigned short> : true_type {};
|
||||||
|
template<> struct is_integral<const int> : true_type {};
|
||||||
|
template<> struct is_integral<const unsigned int> : true_type {};
|
||||||
template<> struct is_integral<const long> : true_type {};
|
template<> struct is_integral<const long> : true_type {};
|
||||||
template<> struct is_integral<const long long> : true_type {};
|
template<> struct is_integral<const long long> : true_type {};
|
||||||
template<> struct is_integral<const unsigned long> : true_type {};
|
template<> struct is_integral<const unsigned long> : true_type {};
|
||||||
@@ -138,29 +139,26 @@ constexpr bool is_integral_v = is_integral<T>::value;
|
|||||||
// is_integer /////////////////////////////////////////////////////////////////
|
// is_integer /////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename T> struct is_integer: false_type {};
|
template<typename T> struct is_integer: false_type {};
|
||||||
template<> struct is_integer<int8_t> : true_type {};
|
template<> struct is_integer<signed char> : true_type {};
|
||||||
template<> struct is_integer<uint8_t> : true_type {};
|
template<> struct is_integer<unsigned char> : true_type {};
|
||||||
template<> struct is_integer<int16_t> : true_type {};
|
template<> struct is_integer<short> : true_type {};
|
||||||
template<> struct is_integer<uint16_t>: true_type {};
|
template<> struct is_integer<unsigned short> : true_type {};
|
||||||
template<> struct is_integer<int32_t> : true_type {};
|
template<> struct is_integer<int> : true_type {};
|
||||||
template<> struct is_integer<uint32_t>: true_type {};
|
template<> struct is_integer<unsigned int> : true_type {};
|
||||||
template<> struct is_integer<int8_t const> : true_type {};
|
|
||||||
template<> struct is_integer<uint8_t const> : true_type {};
|
|
||||||
template<> struct is_integer<int16_t const> : true_type {};
|
|
||||||
template<> struct is_integer<uint16_t const>: true_type {};
|
|
||||||
template<> struct is_integer<int32_t const> : true_type {};
|
|
||||||
template<> struct is_integer<uint32_t const>: true_type {};
|
|
||||||
|
|
||||||
// some of these need to be done with the actual language syntax because no one
|
|
||||||
// can agree on what an (u)int64_t is...
|
|
||||||
template<> struct is_integer<long> : true_type {};
|
template<> struct is_integer<long> : true_type {};
|
||||||
template<> struct is_integer<long long> : true_type {};
|
template<> struct is_integer<long long> : true_type {};
|
||||||
template<> struct is_integer<unsigned long> : true_type {};
|
template<> struct is_integer<unsigned long> : true_type {};
|
||||||
template<> struct is_integer<unsigned long long> : true_type {};
|
template<> struct is_integer<unsigned long long> : true_type {};
|
||||||
template<> struct is_integer<long const>: true_type {};
|
template<> struct is_integer<const signed char> : true_type {};
|
||||||
template<> struct is_integer<long long const>: true_type {};
|
template<> struct is_integer<const unsigned char> : true_type {};
|
||||||
template<> struct is_integer<unsigned long const>: true_type {};
|
template<> struct is_integer<const short> : true_type {};
|
||||||
template<> struct is_integer<unsigned long long const>: true_type {};
|
template<> struct is_integer<const unsigned short> : true_type {};
|
||||||
|
template<> struct is_integer<const int> : true_type {};
|
||||||
|
template<> struct is_integer<const unsigned int> : true_type {};
|
||||||
|
template<> struct is_integer<const long> : true_type {};
|
||||||
|
template<> struct is_integer<const long long> : true_type {};
|
||||||
|
template<> struct is_integer<const unsigned long> : true_type {};
|
||||||
|
template<> struct is_integer<const unsigned long long> : true_type {};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool is_integer_v = is_integer<T>::value;
|
constexpr bool is_integer_v = is_integer<T>::value;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ uint64_t timeMapStrToUuid(int const elemCnt, int const lookups, uint64_t seed =
|
|||||||
// start
|
// start
|
||||||
auto const startTime = steadyNowMs();
|
auto const startTime = steadyNowMs();
|
||||||
for (int i = 0; i < lookups; ++i) {
|
for (int i = 0; i < lookups; ++i) {
|
||||||
auto const &k = keys[rand.gen() % keys.size()];
|
auto const &k = keys[static_cast<size_t>(rand.gen() % keys.size())];
|
||||||
map[k];
|
map[k];
|
||||||
ox::expect(map[k], ox::UUID::fromString(k).unwrap());
|
ox::expect(map[k], ox::UUID::fromString(k).unwrap());
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ uint64_t timeMapUuidToStr(int const elemCnt, int const lookups, uint64_t seed =
|
|||||||
// start
|
// start
|
||||||
auto const startTime = steadyNowMs();
|
auto const startTime = steadyNowMs();
|
||||||
for (int i = 0; i < lookups; ++i) {
|
for (int i = 0; i < lookups; ++i) {
|
||||||
auto const &k = keys[rand.gen() % keys.size()];
|
auto const &k = keys[static_cast<size_t>(rand.gen() % keys.size())];
|
||||||
ox::expect(map[k], k.toString());
|
ox::expect(map[k], k.toString());
|
||||||
}
|
}
|
||||||
return steadyNowMs() - startTime;
|
return steadyNowMs() - startTime;
|
||||||
|
|||||||
Reference in New Issue
Block a user