Rename project, move headers to cx folder for convenience

This commit is contained in:
Gvidas Juknevičius 2025-06-02 16:05:39 +03:00
parent 2a31d770ed
commit 595aeadf7e
Signed by: MCorange
GPG Key ID: 5BE6B533CB76FE86
48 changed files with 202 additions and 898 deletions

View File

@ -1,11 +1,11 @@
#ifndef _H_LIBCP_CLONE
#define _H_LIBCP_CLONE
#ifndef _H_LIBCX_CLONE
#define _H_LIBCX_CLONE
#include <stl.hpp>
#include <cx/stl.hpp>
template <typename T>
concept Format = requires(T t) {
{ t.clone() } -> stl::same_as<T>;
};
#endif // _H_LIBCP_CLONE
#endif // _H_LIBCX_CLONE

View File

@ -1,8 +1,8 @@
#ifndef _H_LIBCP_COLLECTIONS_HASHMAP
#define _H_LIBCP_COLLECTIONS_HASHMAP
#ifndef _H_LIBCX_COLLECTIONS_HASHMAP
#define _H_LIBCX_COLLECTIONS_HASHMAP
#include "option.hpp"
#include <collections/vec.hpp>
#include <cx/option.hpp>
#include <cx/collections/vec.hpp>
#include <stdint.h>
namespace __internal {
@ -32,4 +32,4 @@ public:
Option<V> get(K& key) {}
};
#endif // !_H_LIBCP_COLLECTIONS_HASHMAP
#endif // !_H_LIBCX_COLLECTIONS_HASHMAP

View File

@ -1,10 +1,10 @@
#ifndef _H_LIBCP_COLLECTIONS_VEC
#define _H_LIBCP_COLLECTIONS_VEC
#ifndef _H_LIBCX_COLLECTIONS_VEC
#define _H_LIBCX_COLLECTIONS_VEC
#include <result.hpp>
#include <option.hpp>
#include <cx/result.hpp>
#include <cx/option.hpp>
#include <stdint.h>
#include <stddef.hpp>
#include <cx/stddef.hpp>
template <typename T>
class Vec {
@ -122,4 +122,4 @@ public:
}
};
#endif // _H_LIBCP_COLLECTIONS_VEC
#endif // _H_LIBCX_COLLECTIONS_VEC

View File

@ -1,4 +1,4 @@
#ifndef _H_LIBCP_CONFIG_PLATFORM
#ifndef _H_LIBCX_CONFIG_PLATFORM
#if defined(__linux__)
#define PLATFORM_LINUX
@ -20,4 +20,4 @@
#error This platform is not supported by this library yet
#endif // PLATFORM_UNKNOWN
#endif // !_H_LIBCP_CONFIG_PLATFORM
#endif // !_H_LIBCX_CONFIG_PLATFORM

View File

@ -0,0 +1,8 @@
#ifndef _H_LIBCX_FORMAT
#define _H_LIBCX_FORMAT
namespace format {
#include <cx/format/fmt.hpp>
}
#endif // _H_LIBCX_FORMAT

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_FORMAT_BASE_TYPES
#define _H_LIBCP_FORMAT_BASE_TYPES
#ifndef _H_LIBCX_FORMAT_BASE_TYPES
#define _H_LIBCX_FORMAT_BASE_TYPES
#include <string.hpp>
#include <cx/string.hpp>
extern "C" {
int snprintf(char* __restrict s, size_t maxlen, const char* __restrict format, ...);
@ -51,4 +51,4 @@ struct Formatter<double> {
}
};
#endif // !_H_LIBCP_FORMAT_BASE_TYPES
#endif // !_H_LIBCX_FORMAT_BASE_TYPES

View File

@ -1,13 +1,12 @@
#ifndef _H_LIBCP_FORMAT_FMT
#define _H_LIBCP_FORMAT_FMT
#ifndef _H_LIBCX_FORMAT_FMT
#define _H_LIBCX_FORMAT_FMT
#include <collections/vec.hpp>
#include <cx/collections/vec.hpp>
#include <stddef.h>
#include <stl.hpp>
#include <cx/stl.hpp>
#include <string.h>
#include <string.hpp>
#include "format/base_types.hpp"
#include <cx/string.hpp>
#include <cx/format/base_types.hpp>
template <typename T>
concept Format = requires(T t) {
@ -91,4 +90,4 @@ struct Formatter<Vec<T>> {
};
#endif // __CONCEPT_ONLY
#endif // _H_LIBCP_FORMAT_FMT
#endif // _H_LIBCX_FORMAT_FMT

View File

@ -1,10 +1,10 @@
#ifndef _H_LIBCP_FORMAT_OBJ_FMT_HELPER
#define _H_LIBCP_FORMAT_OBJ_FMT_HELPER
#ifndef _H_LIBCX_FORMAT_OBJ_FMT_HELPER
#define _H_LIBCX_FORMAT_OBJ_FMT_HELPER
#include <stddef.h>
#include <format/fmt.hpp>
#include <string.hpp>
#include <collections/vec.hpp>
#include <cx/format/fmt.hpp>
#include <cx/string.hpp>
#include <cx/collections/vec.hpp>
class ObjFmtHelper {
private:
@ -40,4 +40,4 @@ public:
}
};
#endif // !_H_LIBCP_FORMAT_OBJ_FMT_HELPER
#endif // !_H_LIBCX_FORMAT_OBJ_FMT_HELPER

View File

@ -0,0 +1,21 @@
#ifndef _H_LIBCX_FS_PATH
#define _H_LIBCX_FS_PATH
#include <cx/option.hpp>
#include <cx/string.hpp>
class Path {
private:
Vec<String> parts;
public:
Path();
Path(const char* path);
Path(String path);
void push(const char* path);
void push(String path);
Option<String> pop();
};
#endif // !_H_LIBCX_FS_PATH

View File

@ -1,7 +1,8 @@
#ifndef _H_LIBCX_HASH_HASH
#define _H_LIBCX_HASH_HASH
#include <stdint.h>
#include <stl.hpp>
#include <cx/stl.hpp>
#include <sys/types.h>
#define HASH_SIZE 4
@ -15,3 +16,4 @@ concept Hash = requires(T t) {
} || requires(T t) {
{ Hasher<T>::hash(t) } -> stl::same_as<u_int8_t[HASH_SIZE]>;
};
#endif // !_H_LIBCX_HASH_HASH

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_IO_PRINT
#define _H_LIBCP_IO_PRINT
#ifndef _H_LIBCX_IO_PRINT
#define _H_LIBCX_IO_PRINT
#include <format/fmt.hpp>
#include <cx/format/fmt.hpp>
extern "C" {
int putchar(int c);
@ -22,4 +22,4 @@ void println(const char* fmt, Types... args) {
putchar('\n');
}
#endif // !_H_LIBCP_IO_PRINT
#endif // !_H_LIBCX_IO_PRINT

View File

@ -1,9 +1,10 @@
#include "format/fmt.hpp"
#ifndef _H_LIBCP_LOGGER
#ifndef _H_LIBCX_LOGGER
#define _H_LIBCX_LOGGER
#include <io/print.hpp>
#include <string.hpp>
#include <sync/spinlock.hpp>
#include <cx/io/print.hpp>
#include <cx/string.hpp>
#include <cx/sync/spinlock.hpp>
#include <cx/format/fmt.hpp>
namespace log {
#define LOG_LEVEL_COUNT 4
@ -57,4 +58,4 @@ namespace log {
}
} // namespace log
#endif // !_H_LIBCP_LOGGER
#endif // !_H_LIBCX_LOGGER

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_OPTION
#define _H_LIBCP_OPTION
#include <stl.hpp>
#ifndef _H_LIBCX_OPTION
#define _H_LIBCX_OPTION
#include <cx/stl.hpp>
extern "C" {
int puts(const char* s);
@ -73,4 +73,4 @@ public:
}
};
#endif // _H_LIBCP_OPTION
#endif // _H_LIBCX_OPTION

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_RESULT
#define _H_LIBCP_RESULT
#ifndef _H_LIBCX_RESULT
#define _H_LIBCX_RESULT
#include <stl.hpp>
#include <cx/stl.hpp>
extern "C" {
int puts(const char* s);
@ -134,4 +134,4 @@ public:
}
};
#endif // _H_LIBCP_RESULT
#endif // _H_LIBCX_RESULT

13
src/include/cx/std.hpp Normal file
View File

@ -0,0 +1,13 @@
#ifndef _H_LIBCX
#define _H_LIBCX
#include <cx/stddef.hpp>
#include <stdint.h>
#include <cx/string.hpp>
#include <cx/collections/vec.hpp>
#include <cx/format/fmt.hpp>
#include <cx/stl.hpp>
#include <cx/io/print.hpp>
#endif // _H_LIBCX

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_STDDEF
#ifndef _H_LIBCX_STDDEF
using size_t = decltype(sizeof(int));
using ptrdiff_t = decltype(static_cast<int*>(nullptr) - static_cast<int*>(nullptr));
using nullptr_t = decltype(nullptr);
#endif // !_H_LIBCP_STDDEF
#endif // !_H_LIBCX_STDDEF

21
src/include/cx/stl.hpp Normal file
View File

@ -0,0 +1,21 @@
#ifndef _H_LIBCX_STL
#define _H_LIBCX_STL
namespace stl {
#include <cx/stl/derived_from.hpp>
#include <cx/stl/is_base_of.hpp>
#include <cx/stl/is_convertible.hpp>
#include <cx/stl/is_same.hpp>
#include <cx/stl/move.hpp>
#include <cx/stl/remove_cvref.hpp>
#include <cx/stl/remove_reference.hpp>
#include <cx/stl/add_lvalue_reference.hpp>
#include <cx/stl/add_rvalue_reference.hpp>
#include <cx/stl/integer_sequence.hpp>
#include <cx/stl/is_constructable.hpp>
#include <cx/stl/void_t.hpp>
#include <cx/stl/is_referenceable.hpp>
#include <cx/stl/is_integral.hpp>
} // namespace stl
#endif // _H_LIBCX_STL

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_STL_ADD_LVALUE_REF
#define _H_LIBCP_STL_ADD_LVALUE_REF
#ifndef _H_LIBCX_STL_ADD_LVALUE_REF
#define _H_LIBCX_STL_ADD_LVALUE_REF
#include <stl/is_referenceable.hpp>
#include <cx/stl/is_referenceable.hpp>
#if __has_builtin(__add_lvalue_reference)
@ -32,4 +32,4 @@ struct add_lvalue_reference {
template <class _Tp>
using add_lvalue_reference_t = __add_lvalue_reference_t<_Tp>;
#endif // _H_LIBCP_STL_ADD_LVALUE_REF
#endif // _H_LIBCX_STL_ADD_LVALUE_REF

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_STL_ADD_RVALUE_REF
#define _H_LIBCP_STL_ADD_RVALUE_REF
#ifndef _H_LIBCX_STL_ADD_RVALUE_REF
#define _H_LIBCX_STL_ADD_RVALUE_REF
#include <stl/is_referenceable.hpp>
#include <cx/stl/is_referenceable.hpp>
#if __has_builtin(__add_rvalue_reference)
@ -33,4 +33,4 @@ struct add_rvalue_reference {
template <class _Tp>
using add_rvalue_reference_t = __add_rvalue_reference_t<_Tp>;
#endif // _H_LIBCP_STL_ADD_RVALUE_REF
#endif // _H_LIBCX_STL_ADD_RVALUE_REF

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_STL_DERIVED_FROM
#define _H_LIBCP_STL_DERIVED_FROM
#include <stl/is_base_of.hpp>
#include <stl/is_convertible.hpp>
#include <cx/stl/is_base_of.hpp>
#include <cx/stl/is_convertible.hpp>
template <class _Dp, class _Bp>
concept derived_from = is_base_of_v<_Bp, _Dp> && is_convertible_v<const volatile _Dp*, const volatile _Bp*>;

View File

@ -1,8 +1,8 @@
#ifndef _H_LIBCP_STL_INTEGER_SEQUENCE
#define _H_LIBCP_STL_INTEGER_SEQUENCE
#ifndef _H_LIBCX_STL_INTEGER_SEQUENCE
#define _H_LIBCX_STL_INTEGER_SEQUENCE
#include <stddef.h>
#include <stl/is_integral.hpp>
#include <cx/stl/is_integral.hpp>
template <size_t...>
struct __tuple_indices;
@ -64,4 +64,4 @@ constexpr void __for_each_index_sequence(index_sequence<_Index...>, _Function __
(__func.template operator()<_Index>(), ...);
}
#endif // _H_LIBCP_STL_INTEGER_SEQUENCE
#endif // _H_LIBCX_STL_INTEGER_SEQUENCE

View File

@ -1,5 +1,5 @@
#ifndef _H_LIBCP_STL_INTEGRAL_CONSTANT
#define _H_LIBCP_STL_INTEGRAL_CONSTANT
#ifndef _H_LIBCX_STL_INTEGRAL_CONSTANT
#define _H_LIBCX_STL_INTEGRAL_CONSTANT
template <class _Tp, _Tp __v>
struct integral_constant {
@ -25,4 +25,4 @@ using _BoolConstant = integral_constant<bool, _Val>;
template <bool __b>
using bool_constant = integral_constant<bool, __b>;
#endif // _H_LIBCP_STL_INTEGRAL_CONSTANT
#endif // _H_LIBCX_STL_INTEGRAL_CONSTANT

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_STL_IS_BASE_OF
#define _H_LIBCP_STL_IS_BASE_OF
#ifndef _H_LIBCX_STL_IS_BASE_OF
#define _H_LIBCX_STL_IS_BASE_OF
#include <stl/integral_constant.hpp>
#include <cx/stl/integral_constant.hpp>
template <class _Bp, class _Dp>
struct is_base_of : integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
@ -15,4 +15,4 @@ inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp);
// template <class _Base, class _Derived>
// inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived);
#endif // _H_LIBCP_STL_IS_BASE_OF
#endif // _H_LIBCX_STL_IS_BASE_OF

View File

@ -1,9 +1,9 @@
#ifndef _H_LIBCP_STL_IS_COPY_CONSTRUCTABLE
#define _H_LIBCP_STL_IS_COPY_CONSTRUCTABLE
#ifndef _H_LIBCX_STL_IS_COPY_CONSTRUCTABLE
#define _H_LIBCX_STL_IS_COPY_CONSTRUCTABLE
#include <stl/integral_constant.hpp>
#include <stl/add_lvalue_reference.hpp>
#include <stl/add_rvalue_reference.hpp>
#include <cx/stl/integral_constant.hpp>
#include <cx/stl/add_lvalue_reference.hpp>
#include <cx/stl/add_rvalue_reference.hpp>
template <class _Tp, class... _Args>
struct is_constructible : integral_constant<bool, __is_constructible(_Tp, _Args...)> {};
@ -29,4 +29,4 @@ struct is_default_constructible : integral_constant<bool, __is_constructible(_Tp
template <class _Tp>
inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);
#endif // _H_LIBCP_STL_IS_COPY_CONSTRUCTABLE
#endif // _H_LIBCX_STL_IS_COPY_CONSTRUCTABLE

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_STL_IS_CONVERTIBLE
#define _H_LIBCP_STL_IS_CONVERTIBLE
#ifndef _H_LIBCX_STL_IS_CONVERTIBLE
#define _H_LIBCX_STL_IS_CONVERTIBLE
#include <stl/integral_constant.hpp>
#include <cx/stl/integral_constant.hpp>
template <class _T1, class _T2>
struct is_convertible : integral_constant<bool, __is_convertible(_T1, _T2)> {};
@ -15,4 +15,4 @@ struct is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)
template <class _Tp, class _Up>
inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
#endif // _H_LIBCP_STL_IS_CONVERTIBLE
#endif // _H_LIBCX_STL_IS_CONVERTIBLE

View File

@ -1,8 +1,8 @@
#ifndef _H_LIBCP_STL_IS_INTEGRAL
#define _H_LIBCP_STL_IS_INTEGRAL
#ifndef _H_LIBCX_STL_IS_INTEGRAL
#define _H_LIBCX_STL_IS_INTEGRAL
#include <stl/integral_constant.hpp>
#include <stl/remove_cvref.hpp>
#include <cx/stl/integral_constant.hpp>
#include <cx/stl/remove_cvref.hpp>
// clang-format off
template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
@ -50,4 +50,4 @@ inline constexpr bool is_integral_v = is_integral<_Tp>::value;
#endif // __has_builtin(__is_integral)
#endif // !_H_LIBCP_STL_IS_INTEGRAL
#endif // !_H_LIBCX_STL_IS_INTEGRAL

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_STL_IS_REFERENCEABLE
#define _H_LIBCP_STL_IS_REFERENCEABLE
#ifndef _H_LIBCX_STL_IS_REFERENCEABLE
#define _H_LIBCX_STL_IS_REFERENCEABLE
#include <stl/void_t.hpp>
#include <cx/stl/void_t.hpp>
template <class _Tp, class = void>
inline const bool __is_referenceable_v = false;
@ -12,4 +12,4 @@ inline const bool __is_referenceable_v<_Tp, __void_t<_Tp&>> = true;
template <class _Tp>
concept __referenceable = __is_referenceable_v<_Tp>;
#endif // !_H_LIBCP_STL_IS_REFERENCEABLE
#endif // !_H_LIBCX_STL_IS_REFERENCEABLE

View File

@ -1,5 +1,5 @@
#ifndef _H_LIBCP_STL_IS_SAME
#define _H_LIBCP_STL_IS_SAME
#ifndef _H_LIBCX_STL_IS_SAME
#define _H_LIBCX_STL_IS_SAME
// Basic type trait
template <typename T, typename U>
@ -20,4 +20,4 @@ inline constexpr bool is_same_v = is_same<T, U>::value;
template <typename T, typename U>
concept same_as = is_same_v<T, U> && is_same_v<U, T>;
#endif // _H_LIBCP_STL_IS_SAME
#endif // _H_LIBCX_STL_IS_SAME

View File

@ -1,11 +1,11 @@
#ifndef _H_LIBCP_STL_MOVE
#define _H_LIBCP_STL_MOVE
#ifndef _H_LIBCX_STL_MOVE
#define _H_LIBCX_STL_MOVE
#include "stl/remove_reference.hpp"
#include <cx/stl/remove_reference.hpp>
template <typename T>
constexpr remove_reference_t<T>&& move(T&& t) {
return static_cast<remove_reference_t<T>&&>(t);
}
#endif // _H_LIBCP_STL_MOVE
#endif // _H_LIBCX_STL_MOVE

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_STL_REMOVE_CVREF
#define _H_LIBCP_STL_REMOVE_CVREF
#ifndef _H_LIBCX_STL_REMOVE_CVREF
#define _H_LIBCX_STL_REMOVE_CVREF
#include <stl/is_same.hpp>
#include <cx/stl/is_same.hpp>
// For gcc
// template <class _Tp>
@ -25,4 +25,4 @@ struct remove_cvref {
template <class _Tp>
using remove_cvref_t = __remove_cvref_t<_Tp>;
#endif // _H_LIBCP_STL_REMOVE_CVREF
#endif // _H_LIBCX_STL_REMOVE_CVREF

View File

@ -1,5 +1,5 @@
#ifndef _H_LIBCP_STL_REMOVE_REFERENCE
#define _H_LIBCP_STL_REMOVE_REFERENCE
#ifndef _H_LIBCX_STL_REMOVE_REFERENCE
#define _H_LIBCX_STL_REMOVE_REFERENCE
template <typename T>
struct remove_reference {
@ -19,4 +19,4 @@ struct remove_reference<T&&> {
template <typename T>
using remove_reference_t = typename remove_reference<T>::type;
#endif // _H_LIBCP_STL_REMOVE_REFERENCE
#endif // _H_LIBCX_STL_REMOVE_REFERENCE

View File

@ -1,5 +1,5 @@
#ifndef _H_LIBCP_STL_VOID_T
#define _H_LIBCP_STL_VOID_T
#ifndef _H_LIBCX_STL_VOID_T
#define _H_LIBCX_STL_VOID_T
template <class...>
using void_t = void;
@ -7,4 +7,4 @@ using void_t = void;
template <class...>
using __void_t = void;
#endif // !_H_LIBCP_STL_VOID_T
#endif // !_H_LIBCX_STL_VOID_T

View File

@ -1,7 +1,7 @@
#ifndef _H_LIBCP_STRING
#define _H_LIBCP_STRING
#ifndef _H_LIBCX_STRING
#define _H_LIBCX_STRING
#include "collections/vec.hpp"
#include <cx/collections/vec.hpp>
class String {
private:
@ -25,4 +25,4 @@ public:
String clone();
};
#endif // _H_LIBCP_STRING
#endif // _H_LIBCX_STRING

View File

@ -1,6 +1,6 @@
#ifndef _H_LIBCP_SYNC_MUTEX
#define _H_LIBCP_SYNC_MUTEX
#include <config/platform.hpp>
#ifndef _H_LIBCX_SYNC_MUTEX
#define _H_LIBCX_SYNC_MUTEX
#include <cx/config/platform.hpp>
#ifdef PLATFORM_LINUX
#include <linux/futex.h>
@ -74,4 +74,4 @@ public:
}
};
#endif // !_H_LIBCP_SYNC_MUTEX
#endif // !_H_LIBCX_SYNC_MUTEX

View File

@ -1,6 +1,6 @@
#ifndef _H_LIBCP_SYNC_SPINLOCK
#define _H_LIBCP_SYNC_SPINLOCK
#include <io/print.hpp>
#ifndef _H_LIBCX_SYNC_SPINLOCK
#define _H_LIBCX_SYNC_SPINLOCK
#include <cx/io/print.hpp>
#include <stdatomic.h>
template <typename T>
@ -61,4 +61,4 @@ public:
}
};
#endif // !_H_LIBCP_SYNC_SPINLOCK
#endif // !_H_LIBCX_SYNC_SPINLOCK

View File

@ -1,8 +0,0 @@
#ifndef _H_LIBCP_FORMAT
#define _H_LIBCP_FORMAT
namespace format {
#include <format/fmt.hpp>
}
#endif // _H_LIBCP_FORMAT

View File

@ -1,15 +0,0 @@
#ifndef _H_LIBCP_IO_FS
#define _H_LIBCP_IO_FS
namespace fs {
class File {
File() = default;
~File() = default;
void Open();
};
}
#endif // _H_LIBCP_IO_FS

View File

@ -1,13 +0,0 @@
#ifndef _H_LIBCP
#define _H_LIBCP
#include <stddef.hpp>
#include <stdint.h>
#include <string.hpp>
#include <collections/vec.hpp>
#include <format/fmt.hpp>
#include <stl.hpp>
#include <io/print.hpp>
#endif // _H_LIBCP

View File

@ -1,21 +0,0 @@
#ifndef _H_LIBCP_STL
#define _H_LIBCP_STL
namespace stl {
#include <stl/derived_from.hpp>
#include <stl/is_base_of.hpp>
#include <stl/is_convertible.hpp>
#include <stl/is_same.hpp>
#include <stl/move.hpp>
#include <stl/remove_cvref.hpp>
#include <stl/remove_reference.hpp>
#include <stl/add_lvalue_reference.hpp>
#include <stl/add_rvalue_reference.hpp>
#include <stl/integer_sequence.hpp>
#include <stl/is_constructable.hpp>
#include <stl/void_t.hpp>
#include <stl/is_referenceable.hpp>
#include <stl/is_integral.hpp>
} // namespace stl
#endif // _H_LIBCP_STL

View File

@ -1,701 +0,0 @@
/*===================================================*
| field-reflection version v0.2.1 |
| https://github.com/yosh-matsuda/field-reflection |
| |
| Copyright (c) 2024 Yoshiki Matsuda @yosh-matsuda |
| |
| This software is released under the MIT License. |
| https://opensource.org/license/mit/ |
====================================================*/
// Heavily modified by MCorange <mcorange@mcorangehq.xyz>
#pragma once
#include <stl.hpp>
#include <stddef.h>
namespace field_reflection {
namespace detail {
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wundefined-inline"
#endif
template <typename T, size_t = 0>
struct any_lref {
template <typename U>
requires(!stl::same_as<U, T>)
constexpr operator U&() const&& noexcept; // NOLINT
template <typename U>
requires(!stl::same_as<U, T>)
constexpr operator U&() const& noexcept; // NOLINT
};
template <typename T, size_t = 0>
struct any_rref {
template <typename U>
requires(!stl::same_as<U, T>)
constexpr operator U() const&& noexcept; // NOLINT
};
template <typename T, size_t = 0>
struct any_lref_no_base {
template <typename U>
requires(!stl::is_base_of_v<U, T> && !stl::same_as<U, T>)
constexpr operator U&() const&& noexcept; // NOLINT
template <typename U>
requires(!stl::is_base_of_v<U, T> && !stl::same_as<U, T>)
constexpr operator U&() const& noexcept; // NOLINT
};
template <typename T, size_t = 0>
struct any_rref_no_base {
template <typename U>
requires(!stl::is_base_of_v<U, T> && !stl::same_as<U, T>)
constexpr operator U() const&& noexcept; // NOLINT
};
template <typename T, size_t = 0>
struct any_lref_base {
template <typename U>
requires stl::is_base_of_v<U, T>
constexpr operator U&() const&& noexcept; // NOLINT
template <typename U>
requires stl::is_base_of_v<U, T>
constexpr operator U&() const& noexcept; // NOLINT
};
template <typename T, size_t = 0>
struct any_rref_base {
template <typename U>
requires stl::is_base_of_v<U, T>
constexpr operator U() const&& noexcept; // NOLINT
};
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
template <typename T, size_t ArgNum>
concept constructible = (ArgNum == 0 && requires { T{}; }) || []<size_t I0, size_t... Is>(stl::index_sequence<I0, Is...>) {
if constexpr (stl::is_copy_constructible_v<T>) {
return requires { T{any_lref_no_base<T, I0>(), any_lref<T, Is>()...}; };
} else {
return requires { T{any_rref_no_base<T, I0>(), any_rref<T, Is>()...}; };
}
}(stl::make_index_sequence<ArgNum>());
template <typename T>
concept has_base = []() {
if constexpr (stl::is_copy_constructible_v<T>) {
return requires { T{stl::declval<any_lref_base<T>>()}; };
} else {
return requires { T{stl::declval<any_rref_base<T>>()}; };
}
}();
constexpr size_t macro_max_fields_count = 100;
template <typename T>
constexpr auto max_field_count = stl::min(size_t{macro_max_fields_count}, sizeof(T) * CHAR_BIT); // in consideration of bit field
template <typename T, size_t N>
requires stl::is_aggregate_v<T>
constexpr size_t field_count_impl = []() {
if constexpr (N >= max_field_count<T>) {
return stl::numeric_limits<size_t>::max();
} else if constexpr (constructible<T, N> && !constructible<T, N + 1>) {
return N;
} else {
return field_count_impl<T, N + 1>;
}
}();
template <typename T>
requires stl::is_aggregate_v<T>
constexpr size_t field_count_value = field_count_impl<T, 0>;
template <typename T>
concept field_countable = stl::is_aggregate_v<T> && requires { requires field_count_value<T> <= max_field_count<T>; };
template <field_countable T>
constexpr size_t field_count = field_count_value<T>;
template <typename T>
concept field_referenceable = field_countable<T> && (!has_base<T>);
template <typename T, field_referenceable U = stl::remove_cvref_t<T>>
constexpr auto to_ptr_tuple(T&&) {
static_assert([] { return false; }(), "The supported maximum number of fields in struct must be <= 100.");
}
template <typename T, field_referenceable U = stl::remove_cvref_t<T>>
requires(field_count<U> == 0)
constexpr auto to_ptr_tuple(T&&) {
return stl::tie();
}
template <typename T, field_referenceable U = stl::remove_cvref_t<T>>
requires(field_count<U> == 0)
constexpr auto to_tuple(T&&) {
return stl::tie();
}
#pragma region TO_TUPLE_TEMPLATE_MACRO
// map macro: https://github.com/swansontec/map-macro
#define FIELD_RFL_EVAL0(...) __VA_ARGS__
#define FIELD_RFL_EVAL1(...) FIELD_RFL_EVAL0(FIELD_RFL_EVAL0(FIELD_RFL_EVAL0(__VA_ARGS__)))
#define FIELD_RFL_EVAL2(...) FIELD_RFL_EVAL1(FIELD_RFL_EVAL1(FIELD_RFL_EVAL1(__VA_ARGS__)))
#define FIELD_RFL_EVAL3(...) FIELD_RFL_EVAL2(FIELD_RFL_EVAL2(FIELD_RFL_EVAL2(__VA_ARGS__)))
#define FIELD_RFL_EVAL4(...) FIELD_RFL_EVAL3(FIELD_RFL_EVAL3(FIELD_RFL_EVAL3(__VA_ARGS__)))
#define FIELD_RFL_EVAL(...) FIELD_RFL_EVAL4(FIELD_RFL_EVAL4(FIELD_RFL_EVAL4(__VA_ARGS__)))
#define FIELD_RFL_MAP_END(...)
#define FIELD_RFL_MAP_OUT
#define FIELD_RFL_MAP_COMMA ,
#define FIELD_RFL_MAP_GET_END2() 0, FIELD_RFL_MAP_END
#define FIELD_RFL_MAP_GET_END1(...) FIELD_RFL_MAP_GET_END2
#define FIELD_RFL_MAP_GET_END(...) FIELD_RFL_MAP_GET_END1
#define FIELD_RFL_MAP_NEXT0(test, next, ...) next FIELD_RFL_MAP_OUT
#define FIELD_RFL_MAP_NEXT1(test, next) FIELD_RFL_MAP_NEXT0(test, next, 0)
#define FIELD_RFL_MAP_NEXT(test, next) FIELD_RFL_MAP_NEXT1(FIELD_RFL_MAP_GET_END test, next)
#define FIELD_RFL_MAP0(f, x, peek, ...) f(x) FIELD_RFL_MAP_NEXT(peek, FIELD_RFL_MAP1)(f, peek, __VA_ARGS__)
#define FIELD_RFL_MAP1(f, x, peek, ...) f(x) FIELD_RFL_MAP_NEXT(peek, FIELD_RFL_MAP0)(f, peek, __VA_ARGS__)
#define FIELD_RFL_MAP_LIST_NEXT1(test, next) FIELD_RFL_MAP_NEXT0(test, FIELD_RFL_MAP_COMMA next, 0)
#define FIELD_RFL_MAP_LIST_NEXT(test, next) FIELD_RFL_MAP_LIST_NEXT1(FIELD_RFL_MAP_GET_END test, next)
#define FIELD_RFL_MAP_LIST0(f, x, peek, ...) f(x) FIELD_RFL_MAP_LIST_NEXT(peek, FIELD_RFL_MAP_LIST1)(f, peek, __VA_ARGS__)
#define FIELD_RFL_MAP_LIST1(f, x, peek, ...) f(x) FIELD_RFL_MAP_LIST_NEXT(peek, FIELD_RFL_MAP_LIST0)(f, peek, __VA_ARGS__)
#define FIELD_RFL_MAP(f, ...) FIELD_RFL_EVAL(FIELD_RFL_MAP1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
#define FIELD_RFL_MAP_LIST(f, ...) FIELD_RFL_EVAL(FIELD_RFL_MAP_LIST1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
#define FIELD_RFL_ADDR(x) &x
#define FIELD_RFL_DECLTYPE(x) decltype(x)
#define FIELD_RFL_FORWARD(x) stl::forward<decltype(x)>(x)
#define TO_TUPLE_TEMPLATE(NUM, ...) \
template <typename T, field_referenceable U = stl::remove_cvref_t<T>> \
requires(field_count<U> == NUM) \
constexpr auto to_ptr_tuple(T&& t) { \
auto& [__VA_ARGS__] = t; \
return stl::tuple(FIELD_RFL_MAP_LIST(FIELD_RFL_ADDR, __VA_ARGS__)); \
} \
template <typename T, field_referenceable U = stl::remove_cvref_t<T>> \
requires(field_count<U> == NUM) \
constexpr auto to_tuple(T&& t) { \
auto [__VA_ARGS__] = stl::forward<T>(t); \
return stl::tuple<FIELD_RFL_MAP_LIST(FIELD_RFL_DECLTYPE, __VA_ARGS__)>(FIELD_RFL_MAP_LIST(FIELD_RFL_FORWARD, __VA_ARGS__)); \
}
TO_TUPLE_TEMPLATE(1, p0)
TO_TUPLE_TEMPLATE(2, p0, p1)
TO_TUPLE_TEMPLATE(3, p0, p1, p2)
TO_TUPLE_TEMPLATE(4, p0, p1, p2, p3)
TO_TUPLE_TEMPLATE(5, p0, p1, p2, p3, p4)
TO_TUPLE_TEMPLATE(6, p0, p1, p2, p3, p4, p5)
TO_TUPLE_TEMPLATE(7, p0, p1, p2, p3, p4, p5, p6)
TO_TUPLE_TEMPLATE(8, p0, p1, p2, p3, p4, p5, p6, p7)
TO_TUPLE_TEMPLATE(9, p0, p1, p2, p3, p4, p5, p6, p7, p8)
TO_TUPLE_TEMPLATE(10, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)
TO_TUPLE_TEMPLATE(11, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
TO_TUPLE_TEMPLATE(12, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)
TO_TUPLE_TEMPLATE(13, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)
TO_TUPLE_TEMPLATE(14, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)
TO_TUPLE_TEMPLATE(15, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)
TO_TUPLE_TEMPLATE(16, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)
TO_TUPLE_TEMPLATE(17, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16)
TO_TUPLE_TEMPLATE(18, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)
TO_TUPLE_TEMPLATE(19, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18)
TO_TUPLE_TEMPLATE(20, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19)
TO_TUPLE_TEMPLATE(21, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20)
TO_TUPLE_TEMPLATE(22, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21)
TO_TUPLE_TEMPLATE(23, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22)
TO_TUPLE_TEMPLATE(24, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23)
TO_TUPLE_TEMPLATE(25, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24)
TO_TUPLE_TEMPLATE(26, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25)
TO_TUPLE_TEMPLATE(27, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26)
TO_TUPLE_TEMPLATE(28, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27)
TO_TUPLE_TEMPLATE(29, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28)
TO_TUPLE_TEMPLATE(30, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29)
TO_TUPLE_TEMPLATE(31, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30)
TO_TUPLE_TEMPLATE(32, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31)
TO_TUPLE_TEMPLATE(33, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32)
TO_TUPLE_TEMPLATE(34, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33)
TO_TUPLE_TEMPLATE(35, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34)
TO_TUPLE_TEMPLATE(36, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35)
TO_TUPLE_TEMPLATE(37, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36)
TO_TUPLE_TEMPLATE(38, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37)
TO_TUPLE_TEMPLATE(39, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38)
TO_TUPLE_TEMPLATE(40, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39)
TO_TUPLE_TEMPLATE(41, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40)
TO_TUPLE_TEMPLATE(42, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41)
TO_TUPLE_TEMPLATE(43, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42)
TO_TUPLE_TEMPLATE(44, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43)
TO_TUPLE_TEMPLATE(45, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44)
TO_TUPLE_TEMPLATE(46, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45)
TO_TUPLE_TEMPLATE(47, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46)
TO_TUPLE_TEMPLATE(48, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47)
TO_TUPLE_TEMPLATE(49, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48)
TO_TUPLE_TEMPLATE(50, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49)
TO_TUPLE_TEMPLATE(51, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50)
TO_TUPLE_TEMPLATE(52, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51)
TO_TUPLE_TEMPLATE(53, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52)
TO_TUPLE_TEMPLATE(54, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53)
TO_TUPLE_TEMPLATE(55, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54)
TO_TUPLE_TEMPLATE(56, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55)
TO_TUPLE_TEMPLATE(57, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56)
TO_TUPLE_TEMPLATE(58, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57)
TO_TUPLE_TEMPLATE(59, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58)
TO_TUPLE_TEMPLATE(60, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59)
TO_TUPLE_TEMPLATE(61, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60)
TO_TUPLE_TEMPLATE(62, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61)
TO_TUPLE_TEMPLATE(63, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62)
TO_TUPLE_TEMPLATE(64, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63)
TO_TUPLE_TEMPLATE(65, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64)
TO_TUPLE_TEMPLATE(66, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65)
TO_TUPLE_TEMPLATE(67, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66)
TO_TUPLE_TEMPLATE(68, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67)
TO_TUPLE_TEMPLATE(69, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68)
TO_TUPLE_TEMPLATE(70, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69)
TO_TUPLE_TEMPLATE(71, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70)
TO_TUPLE_TEMPLATE(72, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71)
TO_TUPLE_TEMPLATE(73, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72)
TO_TUPLE_TEMPLATE(74, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73)
TO_TUPLE_TEMPLATE(75, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74)
TO_TUPLE_TEMPLATE(76, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75)
TO_TUPLE_TEMPLATE(77, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76)
TO_TUPLE_TEMPLATE(78, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77)
TO_TUPLE_TEMPLATE(79, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78)
TO_TUPLE_TEMPLATE(80, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79)
TO_TUPLE_TEMPLATE(81, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80)
TO_TUPLE_TEMPLATE(82, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81)
TO_TUPLE_TEMPLATE(83, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82)
TO_TUPLE_TEMPLATE(84, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83)
TO_TUPLE_TEMPLATE(85, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84)
TO_TUPLE_TEMPLATE(86, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85)
TO_TUPLE_TEMPLATE(87, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86)
TO_TUPLE_TEMPLATE(88, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87)
TO_TUPLE_TEMPLATE(89, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88)
TO_TUPLE_TEMPLATE(90, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89)
TO_TUPLE_TEMPLATE(91, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90)
TO_TUPLE_TEMPLATE(92, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90, p91)
TO_TUPLE_TEMPLATE(93, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90, p91, p92)
TO_TUPLE_TEMPLATE(94, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90, p91, p92, p93)
TO_TUPLE_TEMPLATE(95, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90, p91, p92, p93, p94)
TO_TUPLE_TEMPLATE(96, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90, p91, p92, p93, p94, p95)
TO_TUPLE_TEMPLATE(97, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90, p91, p92, p93, p94, p95, p96)
TO_TUPLE_TEMPLATE(98, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90, p91, p92, p93, p94, p95, p96, p97)
TO_TUPLE_TEMPLATE(99, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90, p91, p92, p93, p94, p95, p96, p97, p98)
TO_TUPLE_TEMPLATE(100, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27,
p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50, p51, p52, p53, p54,
p55, p56, p57, p58, p59, p60, p61, p62, p63, p64, p65, p66, p67, p68, p69, p70, p71, p72, p73, p74, p75, p76, p77, p78, p79, p80, p81,
p82, p83, p84, p85, p86, p87, p88, p89, p90, p91, p92, p93, p94, p95, p96, p97, p98, p99)
#undef FIELD_RFL_EVAL0
#undef FIELD_RFL_EVAL1
#undef FIELD_RFL_EVAL2
#undef FIELD_RFL_EVAL3
#undef FIELD_RFL_EVAL4
#undef FIELD_RFL_EVAL
#undef FIELD_RFL_MAP_END
#undef FIELD_RFL_MAP_OUT
#undef FIELD_RFL_MAP_COMMA
#undef FIELD_RFL_MAP_GET_END2
#undef FIELD_RFL_MAP_GET_END1
#undef FIELD_RFL_MAP_GET_END
#undef FIELD_RFL_MAP_NEXT0
#undef FIELD_RFL_MAP_NEXT1
#undef FIELD_RFL_MAP_NEXT
#undef FIELD_RFL_MAP0
#undef FIELD_RFL_MAP1
#undef FIELD_RFL_MAP_LIST_NEXT1
#undef FIELD_RFL_MAP_LIST_NEXT
#undef FIELD_RFL_MAP_LIST0
#undef FIELD_RFL_MAP_LIST1
#undef FIELD_RFL_MAP
#undef FIELD_RFL_MAP_LIST
#undef FIELD_RFL_DECLTYPE
#undef FIELD_RFL_MOVE
#undef FIELD_RFL_TO_TUPLE_TEMPLATE
#pragma endregion TO_TUPLE_TEMPLATE_MACRO
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundefined-internal"
#pragma clang diagnostic ignored "-Wundefined-var-template"
#elif defined(__GNUC__)
#elif defined(_MSC_VER)
#else
#endif
template <typename T>
struct wrapper {
explicit constexpr wrapper(const T& v) : value(v) {}
T value;
static wrapper<T> fake; // NOLINT
};
template <typename T, size_t N> // NOLINT
consteval auto get_ptr() noexcept {
#if defined(__clang__)
return wrapper(stl::get<N>(to_ptr_tuple(wrapper<T>::fake.value)));
#else
return stl::get<N>(to_ptr_tuple(wrapper<T>::fake.value));
#endif
}
#if defined(__clang__)
#pragma clang diagnostic pop
#elif __GNUC__
#elif defined(_MSC_VER)
#else
#endif
template <auto Ptr>
using nontype_template_parameter_helper = void;
template <typename T> // clang-format off
concept field_namable = field_referenceable<T> && (field_count<T> > 0) && requires {
typename nontype_template_parameter_helper<get_ptr<T, 0>()>;
}; // clang-format on
template <typename T, auto Ptr>
consteval stl::string_view get_function_name() {
#if defined(__clang__) && defined(_WIN32)
// clang-cl returns function_name() as __FUNCTION__ instead of __PRETTY_FUNCTION__
return stl::string_view{__PRETTY_FUNCTION__};
#else
return stl::string_view{stl::source_location::current().function_name()};
#endif
}
template <typename T>
consteval stl::string_view get_function_name() {
#if defined(__clang__) && defined(_WIN32)
// clang-cl returns function_name() as __FUNCTION__ instead of __PRETTY_FUNCTION__
return stl::string_view{__PRETTY_FUNCTION__};
#else
return stl::string_view{stl::source_location::current().function_name()};
#endif
}
template <typename T, auto Ptr>
consteval stl::string_view get_field_name() {
struct field_name_detector {
void* dummy;
};
constexpr auto detector_name = get_function_name<field_name_detector, get_ptr<field_name_detector, 0>()>();
constexpr auto dummy_begin = detector_name.rfind(stl::string_view("dummy"));
constexpr auto suffix = detector_name.substr(dummy_begin + stl::string_view("dummy").size());
constexpr auto begin_sentinel = detector_name[dummy_begin - 1];
const auto field_name_raw = get_function_name<T, Ptr>();
const auto last = field_name_raw.rfind(suffix);
const auto begin = field_name_raw.rfind(begin_sentinel, last - 1) + 1;
assert(begin < field_name_raw.size());
assert(last <= field_name_raw.size());
assert(begin < last);
return field_name_raw.substr(begin, last - begin);
}
template <typename T>
using remove_rvalue_reference_t = stl::conditional_t<stl::is_rvalue_reference_v<T>, stl::remove_reference_t<T>, T>;
template <field_namable T, size_t N>
constexpr stl::string_view field_name = get_field_name<T, get_ptr<T, N>()>();
template <field_referenceable T, size_t N>
using field_type = remove_rvalue_reference_t<decltype(stl::get<N>(to_tuple(stl::declval<T&>())))>;
struct type_name_detector {};
template <typename T>
consteval stl::string_view get_type_name() {
#if defined(__GNUC__) || defined(__clang__)
constexpr auto detector_name = get_function_name<type_name_detector>();
constexpr auto dummy = stl::string_view("T = ");
constexpr auto dummy_begin = detector_name.find(dummy) + dummy.size();
constexpr auto dummy2 = stl::string_view("type_name_detector");
constexpr auto dummy_suffix_length = detector_name.size() - detector_name.find(dummy2) - dummy2.size();
constexpr auto type_name_raw = get_function_name<T>();
return type_name_raw.substr(dummy_begin, type_name_raw.size() - dummy_begin - dummy_suffix_length);
#else
constexpr auto detector_name = get_function_name<type_name_detector>();
constexpr auto dummy = stl::string_view("struct field_reflection::detail::type_name_detector");
constexpr auto dummy_begin = detector_name.find(dummy);
constexpr auto dummy_suffix_length = detector_name.size() - dummy_begin - dummy.size();
auto type_name_raw = get_function_name<T>();
auto type_name = type_name_raw.substr(dummy_begin, type_name_raw.size() - dummy_begin - dummy_suffix_length);
if (auto s = stl::string_view("struct "); type_name.starts_with(s)) {
type_name.remove_prefix(s.size());
}
if (auto s = stl::string_view("class "); type_name.starts_with(s)) {
type_name.remove_prefix(s.size());
}
return type_name;
#endif
}
template <class T>
constexpr stl::string_view type_name = get_type_name<T>();
template <size_t N, typename T, field_referenceable U = stl::remove_cvref_t<T>>
constexpr decltype(auto) get_field(T& t) noexcept {
return *stl::get<N>(to_ptr_tuple(t));
}
template <size_t N, typename T, field_referenceable U = stl::remove_cvref_t<T>>
requires stl::is_rvalue_reference_v<T&&>
constexpr auto get_field(T&& t) noexcept {
return stl::get<N>(to_tuple(stl::forward<T>(t)));
}
template <typename T, typename Func, size_t... Is, field_referenceable U = stl::remove_cvref_t<T>>
void for_each_field_impl(T&& t, Func&& func, stl::index_sequence<Is...>) {
if constexpr (requires { (func(get_field<Is>(t)), ...); }) {
(func(get_field<Is>(t)), ...);
} else if constexpr (requires { (func(field_name<U, Is>, get_field<Is>(t)), ...); }) {
(func(field_name<U, Is>, get_field<Is>(t)), ...);
} else {
static_assert([] { return false; }(), "invalid function object for call to for_each_field");
}
}
template <typename T1, typename T2, typename Func, size_t... Is, field_referenceable U = stl::remove_cvref_t<T1>>
void for_each_field_impl(T1&& t1, T2&& t2, Func&& func, stl::index_sequence<Is...>) {
if constexpr (requires { (func(get_field<Is>(t1), get_field<Is>(t2)), ...); }) {
(func(get_field<Is>(t1), get_field<Is>(t2)), ...);
} else if constexpr (requires { (func(field_name<U, Is>, get_field<Is>(t1), get_field<Is>(t2)), ...); }) {
(func(field_name<U, Is>, get_field<Is>(t1), get_field<Is>(t2)), ...);
} else {
static_assert([] { return false; }(), "invalid function object for call to for_each_field");
}
}
template <typename T, typename Func, size_t... Is, field_referenceable U = stl::remove_cvref_t<T>>
bool all_of_field_impl(T&& t, Func&& func, stl::index_sequence<Is...>) {
if constexpr (requires { (func(get_field<Is>(t)) && ...); }) {
return (func(get_field<Is>(t)) && ...);
} else if constexpr (requires { (func(field_name<U, Is>, get_field<Is>(t)) && ...); }) {
return (func(field_name<U, Is>, get_field<Is>(t)) && ...);
} else {
static_assert([] { return false; }(), "invalid function object for call to all_of_field");
}
}
template <typename T1, typename T2, typename Func, size_t... Is, field_referenceable U = stl::remove_cvref_t<T1>>
bool all_of_field_impl(T1&& t1, T2&& t2, Func&& func, stl::index_sequence<Is...>) {
if constexpr (requires { (func(get_field<Is>(t1), get_field<Is>(t2)) && ...); }) {
return (func(get_field<Is>(t1), get_field<Is>(t2)) && ...);
} else if constexpr (requires { (func(field_name<U, Is>, get_field<Is>(t1), get_field<Is>(t2)) && ...); }) {
return (func(field_name<U, Is>, get_field<Is>(t1), get_field<Is>(t2)) && ...);
} else {
static_assert([] { return false; }(), "invalid function object for call to all_of_field");
}
}
template <typename T, typename Func, size_t... Is, field_referenceable U = stl::remove_cvref_t<T>>
bool any_of_field_impl(T&& t, Func&& func, stl::index_sequence<Is...>) {
if constexpr (requires { (func(get_field<Is>(t)) || ...); }) {
return (func(get_field<Is>(t)) || ...);
} else if constexpr (requires { (func(field_name<U, Is>, get_field<Is>(t)) || ...); }) {
return (func(field_name<U, Is>, get_field<Is>(t)) || ...);
} else {
static_assert([] { return false; }(), "invalid function object for call to any_of_field");
}
}
template <typename T1, typename T2, typename Func, size_t... Is, field_referenceable U = stl::remove_cvref_t<T1>>
bool any_of_field_impl(T1&& t1, T2&& t2, Func&& func, stl::index_sequence<Is...>) {
if constexpr (requires { (func(get_field<Is>(t1), get_field<Is>(t2)) || ...); }) {
return (func(get_field<Is>(t1), get_field<Is>(t2)) || ...);
} else if constexpr (requires { (func(field_name<U, Is>, get_field<Is>(t1), get_field<Is>(t2)) || ...); }) {
return (func(field_name<U, Is>, get_field<Is>(t1), get_field<Is>(t2)) || ...);
} else {
static_assert([] { return false; }(), "invalid function object for call to any_of_field");
}
}
} // namespace detail
using detail::field_count;
using detail::field_countable;
using detail::field_namable;
using detail::field_name;
using detail::field_referenceable;
using detail::field_type;
using detail::get_field;
using detail::to_tuple;
using detail::type_name;
template <typename T1, typename T2, typename Func, field_referenceable U1 = stl::remove_cvref_t<T1>, field_referenceable U2 = stl::remove_cvref_t<T2>>
requires stl::is_same_v<U1, U2>
void for_each_field(T1&& t1, T2&& t2, Func&& func) {
detail::for_each_field_impl(stl::forward<T1>(t1), stl::forward<T2>(t2), stl::forward<Func>(func), stl::make_index_sequence<field_count<U1>>());
}
template <typename T, typename Func, field_referenceable U = stl::remove_cvref_t<T>>
void for_each_field(T&& t, Func&& func) {
detail::for_each_field_impl(stl::forward<T>(t), stl::forward<Func>(func), stl::make_index_sequence<field_count<U>>());
}
template <typename T1, typename T2, typename Func, field_referenceable U1 = stl::remove_cvref_t<T1>, field_referenceable U2 = stl::remove_cvref_t<T2>>
requires stl::is_same_v<U1, U2>
bool all_of_field(T1&& t1, T2&& t2, Func&& func) {
return detail::all_of_field_impl(stl::forward<T1>(t1), stl::forward<T2>(t2), stl::forward<Func>(func), stl::make_index_sequence<field_count<U1>>());
}
template <typename T, typename Func, field_referenceable U = stl::remove_cvref_t<T>>
bool all_of_field(T&& t, Func&& func) {
return detail::all_of_field_impl(stl::forward<T>(t), stl::forward<Func>(func), stl::make_index_sequence<field_count<U>>());
}
template <typename T1, typename T2, typename Func, field_referenceable U1 = stl::remove_cvref_t<T1>, field_referenceable U2 = stl::remove_cvref_t<T2>>
requires stl::is_same_v<U1, U2>
bool any_of_field(T1&& t1, T2&& t2, Func&& func) {
return detail::any_of_field_impl(stl::forward<T1>(t1), stl::forward<T2>(t2), stl::forward<Func>(func), stl::make_index_sequence<field_count<U1>>());
}
template <typename T, typename Func, field_referenceable U = stl::remove_cvref_t<T>>
bool any_of_field(T&& t, Func&& func) {
return detail::any_of_field_impl(stl::forward<T>(t), stl::forward<Func>(func), stl::make_index_sequence<field_count<U>>());
}
} // namespace field_reflection

View File

@ -1,5 +1,5 @@
#include <stdlib.h>
#include <std.hpp>
#include <cx/std.hpp>
namespace std {
void __glibcxx_assert_fail(char const* file, int line, char const* func, char const* info) {

View File

@ -1,6 +1,6 @@
#include "io/print.hpp"
#include <cx/io/print.hpp>
#include <string.h>
#include <logger.hpp>
#include <cx/logger.hpp>
using namespace log;

View File

@ -1,12 +1,9 @@
#include <stdlib.h>
#include <unistd.h> /* for write(), also available on Windows */
#include <unistd.h>
extern "C" void* emulate_cc_new(unsigned long len) {
void* p = malloc(len);
if (p == 0) {
/* Don't use stdio (e.g. fputs), because that may want to allocate more
* memory.
*/
(void)!write(2, "out of memory\n", 14);
abort();
}

View File

@ -1,5 +1,5 @@
#include <string.h>
#include <string.hpp>
#include <cx/string.hpp>
String::String(const char* str) {
this->_chars = Vec<char>::from_ptr((char*)str, strlen(str));

BIN
test/test

Binary file not shown.

View File

@ -1,13 +1,13 @@
#include "io/print.hpp"
#include <std.hpp>
#include <format/obj_fmt_helper.hpp>
#include <sync/mutex.hpp>
#include <sync/spinlock.hpp>
#include <cx/io/print.hpp>
#include <cx/std.hpp>
#include <cx/format/obj_fmt_helper.hpp>
#include <cx/sync/mutex.hpp>
#include <cx/sync/spinlock.hpp>
#include <stddef.h>
#include <pthread.h>
#include <unistd.h>
#include <logger.hpp>
#include <cx/logger.hpp>
struct Foo {
int bar = 1;