C++20
This commit is contained in:
parent
8d5a54a37d
commit
3c2cf1bdfd
|
@ -32,7 +32,7 @@ def add_kel_source_files(self, sources, filetype, lib_env=None, shared=False, ta
|
|||
env=Environment(ENV=os.environ, CPPPATH=['#source/kelgin','#source','#','#driver'],
|
||||
CXX='g++',
|
||||
CPPDEFINES=['GIN_UNIX'],
|
||||
CXXFLAGS=['-std=c++17','-g','-Wall','-Wextra'],
|
||||
CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'],
|
||||
LIBS=['gnutls'])
|
||||
env.__class__.add_source_files = add_kel_source_files
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#include "message_container.h"
|
||||
#include "schema.h"
|
||||
#include "string_literal.h"
|
||||
|
||||
|
@ -80,10 +81,10 @@ public:
|
|||
*/
|
||||
template <StringLiteral Literal>
|
||||
typename Container::ElementType<
|
||||
MessageParameterPackIndex<Literal, Keys...>::Value>::Builder
|
||||
MessageParameterKeyIndex<Literal, Keys...>::Value>::Builder
|
||||
init() {
|
||||
constexpr size_t i =
|
||||
MessageParameterPackIndex<Literal, Keys...>::Value;
|
||||
MessageParameterKeyIndex<Literal, Keys...>::Value;
|
||||
|
||||
return init<i>();
|
||||
}
|
||||
|
@ -112,11 +113,11 @@ public:
|
|||
*/
|
||||
template <StringLiteral Literal>
|
||||
typename Container::ElementType<
|
||||
MessageParameterPackIndex<Literal, Keys...>::Value>::Reader
|
||||
MessageParameterKeyIndex<Literal, Keys...>::Value>::Reader
|
||||
get() {
|
||||
// The index of the first match
|
||||
constexpr size_t i =
|
||||
MessageParameterPackIndex<Literal, Keys...>::Value;
|
||||
MessageParameterKeyIndex<Literal, Keys...>::Value;
|
||||
|
||||
return get<i>();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ template <class T, class Container> class Message;
|
|||
template <size_t N, class... T> struct MessageParameterPackType;
|
||||
|
||||
template <class TN, class... T> struct MessageParameterPackType<0, TN, T...> {
|
||||
using Type = T;
|
||||
using Type = TN;
|
||||
};
|
||||
|
||||
template <size_t N, class TN, class... T>
|
||||
|
@ -30,6 +30,19 @@ struct MessageParameterPackIndex<T, TL0, TL...> {
|
|||
1u + MessageParameterPackIndex<T, TL...>::Value;
|
||||
};
|
||||
|
||||
template <StringLiteral... ValueKeys> struct MessageParameterKeyIndex;
|
||||
|
||||
template <StringLiteral V, StringLiteral... Keys>
|
||||
struct MessageParameterKeyIndex<V, V, Keys...> {
|
||||
static constexpr size_t Value = 0u;
|
||||
};
|
||||
|
||||
template <StringLiteral V, StringLiteral Key0, StringLiteral... Keys>
|
||||
struct MessageParameterKeyIndex<V, Key0, Keys...> {
|
||||
static constexpr size_t Value =
|
||||
1u + MessageParameterKeyIndex<V, Keys...>::Value;
|
||||
};
|
||||
|
||||
template <class... V, StringLiteral... Keys>
|
||||
class MessageContainer<schema::Struct<schema::NamedMember<V, Keys>...>> {
|
||||
private:
|
||||
|
@ -108,47 +121,57 @@ public:
|
|||
*/
|
||||
template <class T> struct PrimitiveTypeHelper;
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::SignedIntegral, 1>> {
|
||||
using Type = int8_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::SignedIntegral, 2>> {
|
||||
using Type = int16_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::SignedIntegral, 4>> {
|
||||
using Type = int32_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::SignedIntegral, 8>> {
|
||||
using Type = int64_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::UnsignedIntegral, 1>> {
|
||||
using Type = uint8_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::UnsignedIntegral, 2>> {
|
||||
using Type = uint16_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::UnsignedIntegral, 4>> {
|
||||
using Type = uint32_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::UnsignedIntegral, 8>> {
|
||||
using Type = uint64_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::FloatingPoint, 4>> {
|
||||
using Type = float;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PrimitiveTypeHelper<schema::Primitive<schema::FloatingPoint, 8>> {
|
||||
using Type = double;
|
||||
};
|
||||
|
||||
template <class T, class N> class MessageContainer<schema::Primitive<T, N>> {
|
||||
template <class T, size_t N> class MessageContainer<schema::Primitive<T, N>> {
|
||||
public:
|
||||
using ValueType = PrimitiveTypeHelper<schema::Primitive<T, N>>::Type;
|
||||
|
||||
|
|
|
@ -9,11 +9,12 @@ template <class T, StringLiteral Literal> struct NamedMember {};
|
|||
|
||||
template <class... T> struct Struct;
|
||||
|
||||
template <class... V, class... K> struct Struct<NamedMember<V, K>...> {};
|
||||
template <class... V, StringLiteral... K>
|
||||
struct Struct<NamedMember<V, K>...> {};
|
||||
|
||||
template <class... T> struct Union;
|
||||
|
||||
template <class... V, class... K> struct Union<NamedMember<V, K>...> {};
|
||||
template <class... V, StringLiteral... K> struct Union<NamedMember<V, K>...> {};
|
||||
|
||||
template <class T> struct Array {};
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace gin {
|
|||
* literal. It guarantees compile time uniqueness and thus allows using strings
|
||||
* in template parameters.
|
||||
*/
|
||||
template <template CharT, size_t N> class StringLiteral {
|
||||
template <class CharT, size_t N> class StringLiteral {
|
||||
public:
|
||||
constexpr StringLiteral(const CharT (&input)[N]) noexcept {
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
|
|
Loading…
Reference in New Issue