diff options
author | babenko <babenko@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
commit | cec37806d8847aa3db53bafc9e251d4aaf325c12 (patch) | |
tree | 4a61c191e93e31d9ab423e258c71ab43550ee3d2 /library/cpp/yt/misc | |
parent | 58cd0b86ed99a72df22479e26a20bc1c1e57e65e (diff) | |
download | ydb-cec37806d8847aa3db53bafc9e251d4aaf325c12.tar.gz |
Restoring authorship annotation for <babenko@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yt/misc')
23 files changed, 2364 insertions, 2364 deletions
diff --git a/library/cpp/yt/misc/cast-inl.h b/library/cpp/yt/misc/cast-inl.h index 1920b7c0b7..78884df637 100644 --- a/library/cpp/yt/misc/cast-inl.h +++ b/library/cpp/yt/misc/cast-inl.h @@ -4,9 +4,9 @@ #include "cast.h" #endif -#include <util/string/cast.h> -#include <util/string/printf.h> - +#include <util/string/cast.h> +#include <util/string/printf.h> + #include <type_traits> namespace NYT { @@ -39,29 +39,29 @@ typename std::enable_if<std::is_unsigned<T>::value && std::is_unsigned<S>::value return value <= std::numeric_limits<T>::max(); } -template <class T> -TString FormatInvalidCastValue(T value) -{ - return ::ToString(value); -} - -inline TString FormatInvalidCastValue(signed char value) -{ - return TString("'") + value + TString("'"); -} - -inline TString FormatInvalidCastValue(unsigned char value) -{ - return TString("'") + value + TString("'"); -} - -#ifdef __cpp_char8_t -inline TString FormatInvalidCastValue(char8_t value) -{ - return FormatInvalidCastValue(static_cast<unsigned char>(value)); -} -#endif - +template <class T> +TString FormatInvalidCastValue(T value) +{ + return ::ToString(value); +} + +inline TString FormatInvalidCastValue(signed char value) +{ + return TString("'") + value + TString("'"); +} + +inline TString FormatInvalidCastValue(unsigned char value) +{ + return TString("'") + value + TString("'"); +} + +#ifdef __cpp_char8_t +inline TString FormatInvalidCastValue(char8_t value) +{ + return FormatInvalidCastValue(static_cast<unsigned char>(value)); +} +#endif + } // namespace NDetail template <class T, class S> @@ -79,8 +79,8 @@ T CheckedIntegralCast(S value) { T result; if (!TryIntegralCast<T>(value, &result)) { - throw TSimpleException(Sprintf("Argument value %s is out of expected range", - NDetail::FormatInvalidCastValue(value).c_str())); + throw TSimpleException(Sprintf("Argument value %s is out of expected range", + NDetail::FormatInvalidCastValue(value).c_str())); } return result; } @@ -101,9 +101,9 @@ T CheckedEnumCast(S value) { T result; if (!TryEnumCast<T>(value, &result)) { - throw TSimpleException(Sprintf("Invalid value %d of enum type %s", - static_cast<int>(value), - TEnumTraits<T>::GetTypeName().data())); + throw TSimpleException(Sprintf("Invalid value %d of enum type %s", + static_cast<int>(value), + TEnumTraits<T>::GetTypeName().data())); } return result; } diff --git a/library/cpp/yt/misc/cast.h b/library/cpp/yt/misc/cast.h index c7565c9e6d..5adb3553e9 100644 --- a/library/cpp/yt/misc/cast.h +++ b/library/cpp/yt/misc/cast.h @@ -1,7 +1,7 @@ #pragma once -#include <library/cpp/yt/exception/exception.h> - +#include <library/cpp/yt/exception/exception.h> + namespace NYT { //////////////////////////////////////////////////////////////////////////////// @@ -12,8 +12,8 @@ bool TryIntegralCast(S value, T* result); template <class T, class S> T CheckedIntegralCast(S value); -//////////////////////////////////////////////////////////////////////////////// - +//////////////////////////////////////////////////////////////////////////////// + template <class T, class S> bool TryEnumCast(S value, T* result); diff --git a/library/cpp/yt/misc/enum-inl.h b/library/cpp/yt/misc/enum-inl.h index 59ef704775..7666181aa2 100644 --- a/library/cpp/yt/misc/enum-inl.h +++ b/library/cpp/yt/misc/enum-inl.h @@ -1,41 +1,41 @@ -#pragma once -#ifndef ENUM_INL_H_ -#error "Direct inclusion of this file is not allowed, include enum.h" -// For the sake of sane code completion. -#include "enum.h" -#endif - -#include <util/string/printf.h> -#include <util/string/cast.h> - +#pragma once +#ifndef ENUM_INL_H_ +#error "Direct inclusion of this file is not allowed, include enum.h" +// For the sake of sane code completion. +#include "enum.h" +#endif + +#include <util/string/printf.h> +#include <util/string/cast.h> + #include <algorithm> -#include <stdexcept> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -#define ENUM__CLASS(name, underlyingType, seq) \ - enum class name : underlyingType \ - { \ - PP_FOR_EACH(ENUM__DOMAIN_ITEM, seq) \ - }; - -#define ENUM__DOMAIN_ITEM(item) \ - PP_IF( \ - PP_IS_SEQUENCE(item), \ - ENUM__DOMAIN_ITEM_SEQ, \ - ENUM__DOMAIN_ITEM_ATOMIC \ - )(item)() - -#define ENUM__DOMAIN_ITEM_ATOMIC(item) \ - item PP_COMMA - -#define ENUM__DOMAIN_ITEM_SEQ(seq) \ - PP_ELEMENT(seq, 0) = PP_ELEMENT(seq, 1) PP_COMMA - -//////////////////////////////////////////////////////////////////////////////// - +#include <stdexcept> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +#define ENUM__CLASS(name, underlyingType, seq) \ + enum class name : underlyingType \ + { \ + PP_FOR_EACH(ENUM__DOMAIN_ITEM, seq) \ + }; + +#define ENUM__DOMAIN_ITEM(item) \ + PP_IF( \ + PP_IS_SEQUENCE(item), \ + ENUM__DOMAIN_ITEM_SEQ, \ + ENUM__DOMAIN_ITEM_ATOMIC \ + )(item)() + +#define ENUM__DOMAIN_ITEM_ATOMIC(item) \ + item PP_COMMA + +#define ENUM__DOMAIN_ITEM_SEQ(seq) \ + PP_ELEMENT(seq, 0) = PP_ELEMENT(seq, 1) PP_COMMA + +//////////////////////////////////////////////////////////////////////////////// + namespace NDetail { template <typename TValues> @@ -55,15 +55,15 @@ static constexpr bool AreValuesDistinct(const TValues& values) //////////////////////////////////////////////////////////////////////////////// -#define ENUM__BEGIN_TRAITS(name, underlyingType, isBit, isStringSerializable, seq) \ - struct TEnumTraitsImpl_##name \ - { \ - using TType = name; \ - using TUnderlying = underlyingType; \ - [[maybe_unused]] static constexpr bool IsBitEnum = isBit; \ - [[maybe_unused]] static constexpr bool IsStringSerializableEnum = isStringSerializable; \ - [[maybe_unused]] static constexpr int DomainSize = PP_COUNT(seq); \ - \ +#define ENUM__BEGIN_TRAITS(name, underlyingType, isBit, isStringSerializable, seq) \ + struct TEnumTraitsImpl_##name \ + { \ + using TType = name; \ + using TUnderlying = underlyingType; \ + [[maybe_unused]] static constexpr bool IsBitEnum = isBit; \ + [[maybe_unused]] static constexpr bool IsStringSerializableEnum = isStringSerializable; \ + [[maybe_unused]] static constexpr int DomainSize = PP_COUNT(seq); \ + \ static constexpr std::array<TStringBuf, DomainSize> Names{{ \ PP_FOR_EACH(ENUM__GET_DOMAIN_NAMES_ITEM, seq) \ }}; \ @@ -71,95 +71,95 @@ static constexpr bool AreValuesDistinct(const TValues& values) PP_FOR_EACH(ENUM__GET_DOMAIN_VALUES_ITEM, seq) \ }}; \ \ - static TStringBuf GetTypeName() \ - { \ + static TStringBuf GetTypeName() \ + { \ static constexpr TStringBuf typeName = PP_STRINGIZE(name); \ - return typeName; \ - } \ - \ - static const TStringBuf* FindLiteralByValue(TType value) \ - { \ + return typeName; \ + } \ + \ + static const TStringBuf* FindLiteralByValue(TType value) \ + { \ for (int i = 0; i < DomainSize; ++i) { \ if (Values[i] == value) { \ return &Names[i]; \ } \ } \ - return nullptr; \ - } \ - \ - static bool FindValueByLiteral(TStringBuf literal, TType* result) \ - { \ + return nullptr; \ + } \ + \ + static bool FindValueByLiteral(TStringBuf literal, TType* result) \ + { \ for (int i = 0; i < DomainSize; ++i) { \ if (Names[i] == literal) { \ *result = Values[i]; \ return true; \ } \ } \ - return false; \ - } \ - \ - static const std::array<TStringBuf, DomainSize>& GetDomainNames() \ - { \ + return false; \ + } \ + \ + static const std::array<TStringBuf, DomainSize>& GetDomainNames() \ + { \ return Names; \ - } \ - \ - static const std::array<TType, DomainSize>& GetDomainValues() \ - { \ + } \ + \ + static const std::array<TType, DomainSize>& GetDomainValues() \ + { \ return Values; \ - } \ - \ - static TType FromString(TStringBuf str) \ - { \ - TType value; \ - if (!FindValueByLiteral(str, &value)) { \ - throw ::NYT::TSimpleException(Sprintf("Error parsing %s value %s", \ - PP_STRINGIZE(name), \ - TString(str).Quote().c_str()).c_str()); \ - } \ - return value; \ - } - -#define ENUM__GET_DOMAIN_VALUES_ITEM(item) \ - PP_IF( \ - PP_IS_SEQUENCE(item), \ - ENUM__GET_DOMAIN_VALUES_ITEM_SEQ, \ - ENUM__GET_DOMAIN_VALUES_ITEM_ATOMIC \ - )(item) - -#define ENUM__GET_DOMAIN_VALUES_ITEM_SEQ(seq) \ - ENUM__GET_DOMAIN_VALUES_ITEM_ATOMIC(PP_ELEMENT(seq, 0)) - -#define ENUM__GET_DOMAIN_VALUES_ITEM_ATOMIC(item) \ - TType::item, - -#define ENUM__GET_DOMAIN_NAMES_ITEM(item) \ - PP_IF( \ - PP_IS_SEQUENCE(item), \ - ENUM__GET_DOMAIN_NAMES_ITEM_SEQ, \ - ENUM__GET_DOMAIN_NAMES_ITEM_ATOMIC \ - )(item) - -#define ENUM__GET_DOMAIN_NAMES_ITEM_SEQ(seq) \ - ENUM__GET_DOMAIN_NAMES_ITEM_ATOMIC(PP_ELEMENT(seq, 0)) - -#define ENUM__GET_DOMAIN_NAMES_ITEM_ATOMIC(item) \ + } \ + \ + static TType FromString(TStringBuf str) \ + { \ + TType value; \ + if (!FindValueByLiteral(str, &value)) { \ + throw ::NYT::TSimpleException(Sprintf("Error parsing %s value %s", \ + PP_STRINGIZE(name), \ + TString(str).Quote().c_str()).c_str()); \ + } \ + return value; \ + } + +#define ENUM__GET_DOMAIN_VALUES_ITEM(item) \ + PP_IF( \ + PP_IS_SEQUENCE(item), \ + ENUM__GET_DOMAIN_VALUES_ITEM_SEQ, \ + ENUM__GET_DOMAIN_VALUES_ITEM_ATOMIC \ + )(item) + +#define ENUM__GET_DOMAIN_VALUES_ITEM_SEQ(seq) \ + ENUM__GET_DOMAIN_VALUES_ITEM_ATOMIC(PP_ELEMENT(seq, 0)) + +#define ENUM__GET_DOMAIN_VALUES_ITEM_ATOMIC(item) \ + TType::item, + +#define ENUM__GET_DOMAIN_NAMES_ITEM(item) \ + PP_IF( \ + PP_IS_SEQUENCE(item), \ + ENUM__GET_DOMAIN_NAMES_ITEM_SEQ, \ + ENUM__GET_DOMAIN_NAMES_ITEM_ATOMIC \ + )(item) + +#define ENUM__GET_DOMAIN_NAMES_ITEM_SEQ(seq) \ + ENUM__GET_DOMAIN_NAMES_ITEM_ATOMIC(PP_ELEMENT(seq, 0)) + +#define ENUM__GET_DOMAIN_NAMES_ITEM_ATOMIC(item) \ TStringBuf(PP_STRINGIZE(item)), - + #define ENUM__DECOMPOSE \ - static std::vector<TType> Decompose(TType value) \ - { \ - std::vector<TType> result; \ + static std::vector<TType> Decompose(TType value) \ + { \ + std::vector<TType> result; \ for (int i = 0; i < DomainSize; ++i) { \ if (static_cast<TUnderlying>(value) & static_cast<TUnderlying>(Values[i])) { \ result.push_back(Values[i]); \ } \ } \ - return result; \ - } - + return result; \ + } + #define ENUM__MINMAX \ static constexpr TType GetMinValue() \ - { \ + { \ static_assert(!Values.empty()); \ return *std::min_element(std::begin(Values), std::end(Values)); \ } \ @@ -174,212 +174,212 @@ static constexpr bool AreValuesDistinct(const TValues& values) static_assert(::NYT::NDetail::AreValuesDistinct(Values), \ "Enumeration " #name " contains duplicate values"); -#define ENUM__END_TRAITS(name) \ - }; \ - \ +#define ENUM__END_TRAITS(name) \ + }; \ + \ [[maybe_unused]] inline TEnumTraitsImpl_##name GetEnumTraitsImpl(name) \ - { \ - return TEnumTraitsImpl_##name(); \ - } \ + { \ + return TEnumTraitsImpl_##name(); \ + } \ \ - using ::ToString; \ + using ::ToString; \ [[maybe_unused]] inline TString ToString(name value) \ - { \ - return ::NYT::TEnumTraits<name>::ToString(value); \ - } - -//////////////////////////////////////////////////////////////////////////////// - -template <class T> -std::vector<T> TEnumTraits<T, true>::Decompose(T value) -{ - return TImpl::Decompose(value); -} - -template <class T> -T TEnumTraits<T, true>::FromString(TStringBuf str) -{ - return TImpl::FromString(str); -} - -template <class T> -TString TEnumTraits<T, true>::ToString(TType value) -{ - TString result; - const auto* literal = FindLiteralByValue(value); - if (literal) { - result = *literal; - } else { - result = GetTypeName(); - result += "("; - result += ::ToString(static_cast<TUnderlying>(value)); - result += ")"; - } - return result; -} - -template <class T> -auto TEnumTraits<T, true>::GetDomainValues() -> const std::array<T, DomainSize>& -{ - return TImpl::GetDomainValues(); -} - -template <class T> -auto TEnumTraits<T, true>::GetDomainNames() -> const std::array<TStringBuf, DomainSize>& -{ - return TImpl::GetDomainNames(); -} - -template <class T> -constexpr T TEnumTraits<T, true>::GetMaxValue() -{ - return TImpl::GetMaxValue(); -} - -template <class T> -constexpr T TEnumTraits<T, true>::GetMinValue() -{ - return TImpl::GetMinValue(); -} - -template <class T> -bool TEnumTraits<T, true>::FindValueByLiteral(TStringBuf literal, TType* result) -{ - return TImpl::FindValueByLiteral(literal, result); -} - -template <class T> -const TStringBuf* TEnumTraits<T, true>::FindLiteralByValue(TType value) -{ - return TImpl::FindLiteralByValue(value); -} - -template <class T> -TStringBuf TEnumTraits<T, true>::GetTypeName() -{ - return TImpl::GetTypeName(); -} - -//////////////////////////////////////////////////////////////////////////////// - -template <class E, class T, E Min, E Max> -TEnumIndexedVector<E, T, Min, Max>::TEnumIndexedVector() - : Items_{} -{ } - -template <class E, class T, E Min, E Max> -TEnumIndexedVector<E, T, Min, Max>::TEnumIndexedVector(std::initializer_list<T> elements) - : Items_{} -{ - Y_ASSERT(std::distance(elements.begin(), elements.end()) <= N); - size_t index = 0; - for (const auto& element : elements) { - Items_[index++] = element; - } -} - -template <class E, class T, E Min, E Max> -T& TEnumIndexedVector<E, T, Min, Max>::operator[] (E index) -{ - Y_ASSERT(index >= Min && index <= Max); - return Items_[static_cast<TUnderlying>(index) - static_cast<TUnderlying>(Min)]; -} - -template <class E, class T, E Min, E Max> -const T& TEnumIndexedVector<E, T, Min, Max>::operator[] (E index) const -{ - return const_cast<TEnumIndexedVector&>(*this)[index]; -} - -template <class E, class T, E Min, E Max> -T* TEnumIndexedVector<E, T, Min, Max>::begin() -{ - return Items_.data(); -} - -template <class E, class T, E Min, E Max> -const T* TEnumIndexedVector<E, T, Min, Max>::begin() const -{ - return Items_.data(); -} - -template <class E, class T, E Min, E Max> -T* TEnumIndexedVector<E, T, Min, Max>::end() -{ - return begin() + N; -} - -template <class E, class T, E Min, E Max> -const T* TEnumIndexedVector<E, T, Min, Max>::end() const -{ - return begin() + N; -} - -template <class E, class T, E Min, E Max> -bool TEnumIndexedVector<E, T, Min, Max>::IsDomainValue(E value) -{ - return value >= Min && value <= Max; -} - -//////////////////////////////////////////////////////////////////////////////// - -#define ENUM__BINARY_BITWISE_OPERATOR(T, assignOp, op) \ + { \ + return ::NYT::TEnumTraits<name>::ToString(value); \ + } + +//////////////////////////////////////////////////////////////////////////////// + +template <class T> +std::vector<T> TEnumTraits<T, true>::Decompose(T value) +{ + return TImpl::Decompose(value); +} + +template <class T> +T TEnumTraits<T, true>::FromString(TStringBuf str) +{ + return TImpl::FromString(str); +} + +template <class T> +TString TEnumTraits<T, true>::ToString(TType value) +{ + TString result; + const auto* literal = FindLiteralByValue(value); + if (literal) { + result = *literal; + } else { + result = GetTypeName(); + result += "("; + result += ::ToString(static_cast<TUnderlying>(value)); + result += ")"; + } + return result; +} + +template <class T> +auto TEnumTraits<T, true>::GetDomainValues() -> const std::array<T, DomainSize>& +{ + return TImpl::GetDomainValues(); +} + +template <class T> +auto TEnumTraits<T, true>::GetDomainNames() -> const std::array<TStringBuf, DomainSize>& +{ + return TImpl::GetDomainNames(); +} + +template <class T> +constexpr T TEnumTraits<T, true>::GetMaxValue() +{ + return TImpl::GetMaxValue(); +} + +template <class T> +constexpr T TEnumTraits<T, true>::GetMinValue() +{ + return TImpl::GetMinValue(); +} + +template <class T> +bool TEnumTraits<T, true>::FindValueByLiteral(TStringBuf literal, TType* result) +{ + return TImpl::FindValueByLiteral(literal, result); +} + +template <class T> +const TStringBuf* TEnumTraits<T, true>::FindLiteralByValue(TType value) +{ + return TImpl::FindLiteralByValue(value); +} + +template <class T> +TStringBuf TEnumTraits<T, true>::GetTypeName() +{ + return TImpl::GetTypeName(); +} + +//////////////////////////////////////////////////////////////////////////////// + +template <class E, class T, E Min, E Max> +TEnumIndexedVector<E, T, Min, Max>::TEnumIndexedVector() + : Items_{} +{ } + +template <class E, class T, E Min, E Max> +TEnumIndexedVector<E, T, Min, Max>::TEnumIndexedVector(std::initializer_list<T> elements) + : Items_{} +{ + Y_ASSERT(std::distance(elements.begin(), elements.end()) <= N); + size_t index = 0; + for (const auto& element : elements) { + Items_[index++] = element; + } +} + +template <class E, class T, E Min, E Max> +T& TEnumIndexedVector<E, T, Min, Max>::operator[] (E index) +{ + Y_ASSERT(index >= Min && index <= Max); + return Items_[static_cast<TUnderlying>(index) - static_cast<TUnderlying>(Min)]; +} + +template <class E, class T, E Min, E Max> +const T& TEnumIndexedVector<E, T, Min, Max>::operator[] (E index) const +{ + return const_cast<TEnumIndexedVector&>(*this)[index]; +} + +template <class E, class T, E Min, E Max> +T* TEnumIndexedVector<E, T, Min, Max>::begin() +{ + return Items_.data(); +} + +template <class E, class T, E Min, E Max> +const T* TEnumIndexedVector<E, T, Min, Max>::begin() const +{ + return Items_.data(); +} + +template <class E, class T, E Min, E Max> +T* TEnumIndexedVector<E, T, Min, Max>::end() +{ + return begin() + N; +} + +template <class E, class T, E Min, E Max> +const T* TEnumIndexedVector<E, T, Min, Max>::end() const +{ + return begin() + N; +} + +template <class E, class T, E Min, E Max> +bool TEnumIndexedVector<E, T, Min, Max>::IsDomainValue(E value) +{ + return value >= Min && value <= Max; +} + +//////////////////////////////////////////////////////////////////////////////// + +#define ENUM__BINARY_BITWISE_OPERATOR(T, assignOp, op) \ [[maybe_unused]] inline constexpr T operator op (T lhs, T rhs) \ - { \ - using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ - return T(static_cast<TUnderlying>(lhs) op static_cast<TUnderlying>(rhs)); \ - } \ - \ + { \ + using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ + return T(static_cast<TUnderlying>(lhs) op static_cast<TUnderlying>(rhs)); \ + } \ + \ [[maybe_unused]] inline T& operator assignOp (T& lhs, T rhs) \ - { \ - using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ - lhs = T(static_cast<TUnderlying>(lhs) op static_cast<TUnderlying>(rhs)); \ - return lhs; \ - } - -#define ENUM__UNARY_BITWISE_OPERATOR(T, op) \ + { \ + using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ + lhs = T(static_cast<TUnderlying>(lhs) op static_cast<TUnderlying>(rhs)); \ + return lhs; \ + } + +#define ENUM__UNARY_BITWISE_OPERATOR(T, op) \ [[maybe_unused]] inline constexpr T operator op (T value) \ - { \ - using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ - return T(op static_cast<TUnderlying>(value)); \ - } - -#define ENUM__BIT_SHIFT_OPERATOR(T, assignOp, op) \ + { \ + using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ + return T(op static_cast<TUnderlying>(value)); \ + } + +#define ENUM__BIT_SHIFT_OPERATOR(T, assignOp, op) \ [[maybe_unused]] inline constexpr T operator op (T lhs, size_t rhs) \ - { \ - using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ - return T(static_cast<TUnderlying>(lhs) op rhs); \ - } \ - \ + { \ + using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ + return T(static_cast<TUnderlying>(lhs) op rhs); \ + } \ + \ [[maybe_unused]] inline T& operator assignOp (T& lhs, size_t rhs) \ - { \ - using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ - lhs = T(static_cast<TUnderlying>(lhs) op rhs); \ - return lhs; \ - } - -#define ENUM__BITWISE_OPS(name) \ - ENUM__BINARY_BITWISE_OPERATOR(name, &=, &) \ - ENUM__BINARY_BITWISE_OPERATOR(name, |=, | ) \ - ENUM__BINARY_BITWISE_OPERATOR(name, ^=, ^) \ - ENUM__UNARY_BITWISE_OPERATOR(name, ~) \ - ENUM__BIT_SHIFT_OPERATOR(name, <<=, << ) \ - ENUM__BIT_SHIFT_OPERATOR(name, >>=, >> ) - -//////////////////////////////////////////////////////////////////////////////// - + { \ + using TUnderlying = typename TEnumTraits<T>::TUnderlying; \ + lhs = T(static_cast<TUnderlying>(lhs) op rhs); \ + return lhs; \ + } + +#define ENUM__BITWISE_OPS(name) \ + ENUM__BINARY_BITWISE_OPERATOR(name, &=, &) \ + ENUM__BINARY_BITWISE_OPERATOR(name, |=, | ) \ + ENUM__BINARY_BITWISE_OPERATOR(name, ^=, ^) \ + ENUM__UNARY_BITWISE_OPERATOR(name, ~) \ + ENUM__BIT_SHIFT_OPERATOR(name, <<=, << ) \ + ENUM__BIT_SHIFT_OPERATOR(name, >>=, >> ) + +//////////////////////////////////////////////////////////////////////////////// + template <typename E, typename> bool Any(E value) -{ - return static_cast<typename TEnumTraits<E>::TUnderlying>(value) != 0; -} - +{ + return static_cast<typename TEnumTraits<E>::TUnderlying>(value) != 0; +} + template <class E, typename> bool None(E value) -{ - return static_cast<typename TEnumTraits<E>::TUnderlying>(value) == 0; -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +{ + return static_cast<typename TEnumTraits<E>::TUnderlying>(value) == 0; +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/library/cpp/yt/misc/enum.h b/library/cpp/yt/misc/enum.h index 894364aa43..b30d20dbe0 100644 --- a/library/cpp/yt/misc/enum.h +++ b/library/cpp/yt/misc/enum.h @@ -1,113 +1,113 @@ -#pragma once - -#include "preprocessor.h" - -#include <util/generic/strbuf.h> - -#include <stdexcept> -#include <type_traits> -#include <array> -#include <vector> - -#include <library/cpp/yt/exception/exception.h> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// -/* - * Smart enumerations augment C++ enum classes with a bunch of reflection - * capabilities accessible via TEnumTraits class specialization. - * - * Please refer to the unit test for an actual example of usage - * (unittests/enum_ut.cpp). - */ - +#pragma once + +#include "preprocessor.h" + +#include <util/generic/strbuf.h> + +#include <stdexcept> +#include <type_traits> +#include <array> +#include <vector> + +#include <library/cpp/yt/exception/exception.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// +/* + * Smart enumerations augment C++ enum classes with a bunch of reflection + * capabilities accessible via TEnumTraits class specialization. + * + * Please refer to the unit test for an actual example of usage + * (unittests/enum_ut.cpp). + */ + // Actual overload must be provided with defines DEFINE_ENUM_XXX (see below). template <class T> void GetEnumTraitsImpl(T); -template < - class T, +template < + class T, bool = std::is_enum<T>::value && !std::is_convertible<T, int>::value && !std::is_same<void, decltype(GetEnumTraitsImpl(T()))>::value -> -struct TEnumTraits -{ - static constexpr bool IsEnum = false; - static constexpr bool IsBitEnum = false; - static constexpr bool IsStringSerializableEnum = false; -}; - -template <class T> -struct TEnumTraits<T, true> -{ - using TImpl = decltype(GetEnumTraitsImpl(T())); - using TType = T; - using TUnderlying = typename TImpl::TUnderlying; - - static constexpr bool IsEnum = true; - static constexpr bool IsBitEnum = TImpl::IsBitEnum; - static constexpr bool IsStringSerializableEnum = TImpl::IsStringSerializableEnum; - - static constexpr int DomainSize = TImpl::DomainSize; - - static TStringBuf GetTypeName(); - - static const TStringBuf* FindLiteralByValue(TType value); - static bool FindValueByLiteral(TStringBuf literal, TType* result); - - static const std::array<TStringBuf, DomainSize>& GetDomainNames(); - static const std::array<TType, DomainSize>& GetDomainValues(); - - static TType FromString(TStringBuf str); - static TString ToString(TType value); - - // For non-bit enums only. - static constexpr TType GetMinValue(); - static constexpr TType GetMaxValue(); - - // For bit enums only. - static std::vector<TType> Decompose(TType value); - - // LLVM SmallDenseMap interop. - // This should only be used for enums whose underlying type has big enough range - // (see getEmptyKey and getTombstoneKey functions). - struct TDenseMapInfo - { - static inline TType getEmptyKey() - { - return static_cast<TType>(-1); - } - - static inline TType getTombstoneKey() - { - return static_cast<TType>(-2); - } - - static unsigned getHashValue(const TType& key) - { - return static_cast<unsigned>(key) * 37U; - } - - static bool isEqual(const TType& lhs, const TType& rhs) - { - return lhs == rhs; - } - }; -}; - -//////////////////////////////////////////////////////////////////////////////// - -//! Defines a smart enumeration with a specific underlying type. -/*! - * \param name Enumeration name. - * \param seq Enumeration domain encoded as a <em>sequence</em>. - * \param underlyingType Underlying type. - */ -#define DEFINE_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ - ENUM__CLASS(name, underlyingType, seq) \ - ENUM__BEGIN_TRAITS(name, underlyingType, false, false, seq) \ +> +struct TEnumTraits +{ + static constexpr bool IsEnum = false; + static constexpr bool IsBitEnum = false; + static constexpr bool IsStringSerializableEnum = false; +}; + +template <class T> +struct TEnumTraits<T, true> +{ + using TImpl = decltype(GetEnumTraitsImpl(T())); + using TType = T; + using TUnderlying = typename TImpl::TUnderlying; + + static constexpr bool IsEnum = true; + static constexpr bool IsBitEnum = TImpl::IsBitEnum; + static constexpr bool IsStringSerializableEnum = TImpl::IsStringSerializableEnum; + + static constexpr int DomainSize = TImpl::DomainSize; + + static TStringBuf GetTypeName(); + + static const TStringBuf* FindLiteralByValue(TType value); + static bool FindValueByLiteral(TStringBuf literal, TType* result); + + static const std::array<TStringBuf, DomainSize>& GetDomainNames(); + static const std::array<TType, DomainSize>& GetDomainValues(); + + static TType FromString(TStringBuf str); + static TString ToString(TType value); + + // For non-bit enums only. + static constexpr TType GetMinValue(); + static constexpr TType GetMaxValue(); + + // For bit enums only. + static std::vector<TType> Decompose(TType value); + + // LLVM SmallDenseMap interop. + // This should only be used for enums whose underlying type has big enough range + // (see getEmptyKey and getTombstoneKey functions). + struct TDenseMapInfo + { + static inline TType getEmptyKey() + { + return static_cast<TType>(-1); + } + + static inline TType getTombstoneKey() + { + return static_cast<TType>(-2); + } + + static unsigned getHashValue(const TType& key) + { + return static_cast<unsigned>(key) * 37U; + } + + static bool isEqual(const TType& lhs, const TType& rhs) + { + return lhs == rhs; + } + }; +}; + +//////////////////////////////////////////////////////////////////////////////// + +//! Defines a smart enumeration with a specific underlying type. +/*! + * \param name Enumeration name. + * \param seq Enumeration domain encoded as a <em>sequence</em>. + * \param underlyingType Underlying type. + */ +#define DEFINE_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ + ENUM__CLASS(name, underlyingType, seq) \ + ENUM__BEGIN_TRAITS(name, underlyingType, false, false, seq) \ ENUM__MINMAX \ ENUM__VALIDATE_UNIQUE(name) \ ENUM__END_TRAITS(name) @@ -118,26 +118,26 @@ struct TEnumTraits<T, true> ENUM__CLASS(name, underlyingType, seq) \ ENUM__BEGIN_TRAITS(name, underlyingType, false, false, seq) \ ENUM__MINMAX \ - ENUM__END_TRAITS(name) - -//! Defines a smart enumeration with the default |int| underlying type. -#define DEFINE_ENUM(name, seq) \ - DEFINE_ENUM_WITH_UNDERLYING_TYPE(name, int, seq) - -//! Defines a smart enumeration with a specific underlying type. -/*! - * \param name Enumeration name. - * \param seq Enumeration domain encoded as a <em>sequence</em>. - * \param underlyingType Underlying type. - */ -#define DEFINE_BIT_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ - ENUM__CLASS(name, underlyingType, seq) \ - ENUM__BEGIN_TRAITS(name, underlyingType, true, false, seq) \ + ENUM__END_TRAITS(name) + +//! Defines a smart enumeration with the default |int| underlying type. +#define DEFINE_ENUM(name, seq) \ + DEFINE_ENUM_WITH_UNDERLYING_TYPE(name, int, seq) + +//! Defines a smart enumeration with a specific underlying type. +/*! + * \param name Enumeration name. + * \param seq Enumeration domain encoded as a <em>sequence</em>. + * \param underlyingType Underlying type. + */ +#define DEFINE_BIT_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ + ENUM__CLASS(name, underlyingType, seq) \ + ENUM__BEGIN_TRAITS(name, underlyingType, true, false, seq) \ ENUM__DECOMPOSE \ ENUM__VALIDATE_UNIQUE(name) \ - ENUM__END_TRAITS(name) \ - ENUM__BITWISE_OPS(name) - + ENUM__END_TRAITS(name) \ + ENUM__BITWISE_OPS(name) + //! Defines a smart enumeration with a specific underlying type. //! Duplicate enumeration values are allowed. /*! @@ -152,23 +152,23 @@ struct TEnumTraits<T, true> ENUM__END_TRAITS(name) \ ENUM__BITWISE_OPS(name) -//! Defines a smart enumeration with the default |unsigned| underlying type. -/*! - * \param name Enumeration name. - * \param seq Enumeration domain encoded as a <em>sequence</em>. - */ -#define DEFINE_BIT_ENUM(name, seq) \ - DEFINE_BIT_ENUM_WITH_UNDERLYING_TYPE(name, unsigned, seq) - -//! Defines a smart enumeration with a specific underlying type and IsStringSerializable attribute. -/*! - * \param name Enumeration name. - * \param seq Enumeration domain encoded as a <em>sequence</em>. - * \param underlyingType Underlying type. - */ -#define DEFINE_STRING_SERIALIZABLE_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ - ENUM__CLASS(name, underlyingType, seq) \ - ENUM__BEGIN_TRAITS(name, underlyingType, false, true, seq) \ +//! Defines a smart enumeration with the default |unsigned| underlying type. +/*! + * \param name Enumeration name. + * \param seq Enumeration domain encoded as a <em>sequence</em>. + */ +#define DEFINE_BIT_ENUM(name, seq) \ + DEFINE_BIT_ENUM_WITH_UNDERLYING_TYPE(name, unsigned, seq) + +//! Defines a smart enumeration with a specific underlying type and IsStringSerializable attribute. +/*! + * \param name Enumeration name. + * \param seq Enumeration domain encoded as a <em>sequence</em>. + * \param underlyingType Underlying type. + */ +#define DEFINE_STRING_SERIALIZABLE_ENUM_WITH_UNDERLYING_TYPE(name, underlyingType, seq) \ + ENUM__CLASS(name, underlyingType, seq) \ + ENUM__BEGIN_TRAITS(name, underlyingType, false, true, seq) \ ENUM__MINMAX \ ENUM__VALIDATE_UNIQUE(name) \ ENUM__END_TRAITS(name) \ @@ -179,65 +179,65 @@ struct TEnumTraits<T, true> ENUM__CLASS(name, underlyingType, seq) \ ENUM__BEGIN_TRAITS(name, underlyingType, false, true, seq) \ ENUM__MINMAX \ - ENUM__END_TRAITS(name) - -//! Defines a smart enumeration with the default |int| underlying type and IsStringSerializable attribute. -#define DEFINE_STRING_SERIALIZABLE_ENUM(name, seq) \ - DEFINE_STRING_SERIALIZABLE_ENUM_WITH_UNDERLYING_TYPE(name, int, seq) - -//////////////////////////////////////////////////////////////////////////////// - -//! A statically sized vector with elements of type |T| indexed by -//! the items of enumeration type |E|. -/*! - * Items are value-initialized on construction. - */ -template < - class E, - class T, - E Min = TEnumTraits<E>::GetMinValue(), - E Max = TEnumTraits<E>::GetMaxValue() -> -class TEnumIndexedVector -{ -public: - using TIndex = E; - using TValue = T; - - TEnumIndexedVector(); - TEnumIndexedVector(std::initializer_list<T> elements); - - T& operator[] (E index); - const T& operator[] (E index) const; - - // STL interop. - T* begin(); - const T* begin() const; - T* end(); - const T* end() const; - - static bool IsDomainValue(E value); - -private: - using TUnderlying = typename TEnumTraits<E>::TUnderlying; - static constexpr int N = static_cast<TUnderlying>(Max) - static_cast<TUnderlying>(Min) + 1; - std::array<T, N> Items_; -}; - -//////////////////////////////////////////////////////////////////////////////// - -//! Returns |true| iff the enumeration value is not bitwise zero. + ENUM__END_TRAITS(name) + +//! Defines a smart enumeration with the default |int| underlying type and IsStringSerializable attribute. +#define DEFINE_STRING_SERIALIZABLE_ENUM(name, seq) \ + DEFINE_STRING_SERIALIZABLE_ENUM_WITH_UNDERLYING_TYPE(name, int, seq) + +//////////////////////////////////////////////////////////////////////////////// + +//! A statically sized vector with elements of type |T| indexed by +//! the items of enumeration type |E|. +/*! + * Items are value-initialized on construction. + */ +template < + class E, + class T, + E Min = TEnumTraits<E>::GetMinValue(), + E Max = TEnumTraits<E>::GetMaxValue() +> +class TEnumIndexedVector +{ +public: + using TIndex = E; + using TValue = T; + + TEnumIndexedVector(); + TEnumIndexedVector(std::initializer_list<T> elements); + + T& operator[] (E index); + const T& operator[] (E index) const; + + // STL interop. + T* begin(); + const T* begin() const; + T* end(); + const T* end() const; + + static bool IsDomainValue(E value); + +private: + using TUnderlying = typename TEnumTraits<E>::TUnderlying; + static constexpr int N = static_cast<TUnderlying>(Max) - static_cast<TUnderlying>(Min) + 1; + std::array<T, N> Items_; +}; + +//////////////////////////////////////////////////////////////////////////////// + +//! Returns |true| iff the enumeration value is not bitwise zero. template <typename E, typename = std::enable_if_t<NYT::TEnumTraits<E>::IsBitEnum, E>> bool Any(E value); - -//! Returns |true| iff the enumeration value is bitwise zero. + +//! Returns |true| iff the enumeration value is bitwise zero. template <typename E, typename = std::enable_if_t<NYT::TEnumTraits<E>::IsBitEnum, E>> bool None(E value); - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT - -#define ENUM_INL_H_ -#include "enum-inl.h" -#undef ENUM_INL_H_ + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT + +#define ENUM_INL_H_ +#include "enum-inl.h" +#undef ENUM_INL_H_ diff --git a/library/cpp/yt/misc/guid-inl.h b/library/cpp/yt/misc/guid-inl.h index 2d94b5701b..3f0768cca2 100644 --- a/library/cpp/yt/misc/guid-inl.h +++ b/library/cpp/yt/misc/guid-inl.h @@ -1,76 +1,76 @@ -#ifndef GUID_INL_H_ -#error "Direct inclusion of this file is not allowed, include guid.h" +#ifndef GUID_INL_H_ +#error "Direct inclusion of this file is not allowed, include guid.h" // For the sake of sane code completion. #include "guid.h" -#endif - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -Y_FORCE_INLINE constexpr TGuid::TGuid() - : Parts32{} -{ } - -Y_FORCE_INLINE constexpr TGuid::TGuid(ui32 part0, ui32 part1, ui32 part2, ui32 part3) - : Parts32{part0, part1, part2, part3} -{ } - -Y_FORCE_INLINE constexpr TGuid::TGuid(ui64 part0, ui64 part1) - : Parts64{part0, part1} -{ } - -Y_FORCE_INLINE bool TGuid::IsEmpty() const -{ - return Parts64[0] == 0 && Parts64[1] == 0; -} - -Y_FORCE_INLINE TGuid::operator bool() const +#endif + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +Y_FORCE_INLINE constexpr TGuid::TGuid() + : Parts32{} +{ } + +Y_FORCE_INLINE constexpr TGuid::TGuid(ui32 part0, ui32 part1, ui32 part2, ui32 part3) + : Parts32{part0, part1, part2, part3} +{ } + +Y_FORCE_INLINE constexpr TGuid::TGuid(ui64 part0, ui64 part1) + : Parts64{part0, part1} +{ } + +Y_FORCE_INLINE bool TGuid::IsEmpty() const +{ + return Parts64[0] == 0 && Parts64[1] == 0; +} + +Y_FORCE_INLINE TGuid::operator bool() const { return !IsEmpty(); } -//////////////////////////////////////////////////////////////////////////////// - +//////////////////////////////////////////////////////////////////////////////// + Y_FORCE_INLINE bool operator == (TGuid lhs, TGuid rhs) -{ - return lhs.Parts64[0] == rhs.Parts64[0] && - lhs.Parts64[1] == rhs.Parts64[1]; -} - +{ + return lhs.Parts64[0] == rhs.Parts64[0] && + lhs.Parts64[1] == rhs.Parts64[1]; +} + Y_FORCE_INLINE bool operator != (TGuid lhs, TGuid rhs) -{ - return !(lhs == rhs); -} - +{ + return !(lhs == rhs); +} + Y_FORCE_INLINE bool operator < (TGuid lhs, TGuid rhs) -{ -#ifdef __GNUC__ - ui64 lhs0 = __builtin_bswap64(lhs.Parts64[0]); - ui64 rhs0 = __builtin_bswap64(rhs.Parts64[0]); - if (lhs0 < rhs0) { - return true; - } - if (lhs0 > rhs0) { - return false; - } - ui64 lhs1 = __builtin_bswap64(lhs.Parts64[1]); - ui64 rhs1 = __builtin_bswap64(rhs.Parts64[1]); - return lhs1 < rhs1; -#else - return memcmp(&lhs, &rhs, sizeof(TGuid)) < 0; -#endif -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT - +{ +#ifdef __GNUC__ + ui64 lhs0 = __builtin_bswap64(lhs.Parts64[0]); + ui64 rhs0 = __builtin_bswap64(rhs.Parts64[0]); + if (lhs0 < rhs0) { + return true; + } + if (lhs0 > rhs0) { + return false; + } + ui64 lhs1 = __builtin_bswap64(lhs.Parts64[1]); + ui64 rhs1 = __builtin_bswap64(rhs.Parts64[1]); + return lhs1 < rhs1; +#else + return memcmp(&lhs, &rhs, sizeof(TGuid)) < 0; +#endif +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT + Y_FORCE_INLINE size_t THash<NYT::TGuid>::operator()(const NYT::TGuid& guid) const -{ - const size_t p = 1000000009; // prime number - return guid.Parts32[0] + - guid.Parts32[1] * p + - guid.Parts32[2] * p * p + - guid.Parts32[3] * p * p * p; -} +{ + const size_t p = 1000000009; // prime number + return guid.Parts32[0] + + guid.Parts32[1] * p + + guid.Parts32[2] * p * p + + guid.Parts32[3] * p * p * p; +} diff --git a/library/cpp/yt/misc/guid.cpp b/library/cpp/yt/misc/guid.cpp index 882787d7a2..f08ca7c99f 100644 --- a/library/cpp/yt/misc/guid.cpp +++ b/library/cpp/yt/misc/guid.cpp @@ -1,13 +1,13 @@ -#include "guid.h" - -#include <util/random/random.h> - -#include <util/string/printf.h> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - +#include "guid.h" + +#include <util/random/random.h> + +#include <util/string/printf.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + namespace { const ui8 HexDigits1[16] = { @@ -37,23 +37,23 @@ const ui16 HexDigits2[256] = { //////////////////////////////////////////////////////////////////////////////// -TGuid TGuid::Create() -{ - return TGuid(RandomNumber<ui64>(), RandomNumber<ui64>()); -} - -TGuid TGuid::FromString(TStringBuf str) -{ - TGuid guid; - if (!FromString(str, &guid)) { - throw TSimpleException(Sprintf("Error parsing GUID \"%s\"", - TString(str).c_str())); - } - return guid; -} - -bool TGuid::FromString(TStringBuf str, TGuid* result) -{ +TGuid TGuid::Create() +{ + return TGuid(RandomNumber<ui64>(), RandomNumber<ui64>()); +} + +TGuid TGuid::FromString(TStringBuf str) +{ + TGuid guid; + if (!FromString(str, &guid)) { + throw TSimpleException(Sprintf("Error parsing GUID \"%s\"", + TString(str).c_str())); + } + return guid; +} + +bool TGuid::FromString(TStringBuf str, TGuid* result) +{ size_t partId = 3; ui64 partValue = 0; bool isEmptyPart = true; @@ -93,18 +93,18 @@ bool TGuid::FromString(TStringBuf str, TGuid* result) } if (partId != 0 || isEmptyPart) { // x-y or x-y-z- - return false; - } + return false; + } result->Parts32[partId] = static_cast<ui32>(partValue); - return true; -} - + return true; +} + TGuid TGuid::FromStringHex32(TStringBuf str) { TGuid guid; if (!FromStringHex32(str, &guid)) { - throw TSimpleException(Sprintf("Error parsing Hex32 GUID \"%s\"", - TString(str).c_str())); + throw TSimpleException(Sprintf("Error parsing Hex32 GUID \"%s\"", + TString(str).c_str())); } return guid; } @@ -131,7 +131,7 @@ bool TGuid::FromStringHex32(TStringBuf str, TGuid* result) } return digit; }; - + for (size_t j = 0; j < 16; ++j) { result->ReversedParts8[15 - j] = parseChar() * 16 + parseChar(); } @@ -198,6 +198,6 @@ char* WriteGuidToBuffer(char* ptr, TGuid value) return ptr; } -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/library/cpp/yt/misc/guid.h b/library/cpp/yt/misc/guid.h index ec4ba3526a..1517c006ed 100644 --- a/library/cpp/yt/misc/guid.h +++ b/library/cpp/yt/misc/guid.h @@ -1,14 +1,14 @@ -#pragma once - +#pragma once + #include <util/generic/string.h> -#include <util/generic/typetraits.h> - -#include <library/cpp/yt/exception/exception.h> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - +#include <util/generic/typetraits.h> + +#include <library/cpp/yt/exception/exception.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + //! TGuid is 16-byte value that might be interpreted as four little-endian 32-bit integers or two 64-bit little-endian integers. /*! * *-------------------------*-------------------------* @@ -35,75 +35,75 @@ namespace NYT { * 34 is byte [9] * ff is byte [15] */ -struct TGuid -{ - union - { - ui32 Parts32[4]; - ui64 Parts64[2]; +struct TGuid +{ + union + { + ui32 Parts32[4]; + ui64 Parts64[2]; ui8 ReversedParts8[16]; - }; - - //! Constructs a null (zero) guid. - constexpr TGuid(); - - //! Constructs guid from parts. - constexpr TGuid(ui32 part0, ui32 part1, ui32 part2, ui32 part3); - - //! Constructs guid from parts. - constexpr TGuid(ui64 part0, ui64 part1); - - //! Copies an existing guid. - TGuid(const TGuid& other) = default; - - //! Checks if TGuid is zero. - bool IsEmpty() const; - + }; + + //! Constructs a null (zero) guid. + constexpr TGuid(); + + //! Constructs guid from parts. + constexpr TGuid(ui32 part0, ui32 part1, ui32 part2, ui32 part3); + + //! Constructs guid from parts. + constexpr TGuid(ui64 part0, ui64 part1); + + //! Copies an existing guid. + TGuid(const TGuid& other) = default; + + //! Checks if TGuid is zero. + bool IsEmpty() const; + //! Converts TGuid to bool, returns |false| iff TGuid is zero. explicit operator bool() const; - //! Creates a new instance. - static TGuid Create(); - - //! Parses guid from TStringBuf, throws an exception if something went wrong. - static TGuid FromString(TStringBuf str); - - //! Parses guid from TStringBuf, returns |true| if everything was ok. - static bool FromString(TStringBuf str, TGuid* guid); + //! Creates a new instance. + static TGuid Create(); + + //! Parses guid from TStringBuf, throws an exception if something went wrong. + static TGuid FromString(TStringBuf str); + + //! Parses guid from TStringBuf, returns |true| if everything was ok. + static bool FromString(TStringBuf str, TGuid* guid); //! Same as FromString, but expects exactly 32 hex digits without dashes. static TGuid FromStringHex32(TStringBuf str); //! Same as TryFromString, but expects exactly 32 hex digits without dashes. static bool FromStringHex32(TStringBuf str, TGuid* guid); -}; - +}; + bool operator == (TGuid lhs, TGuid rhs); bool operator != (TGuid lhs, TGuid rhs); bool operator < (TGuid lhs, TGuid rhs); - -//////////////////////////////////////////////////////////////////////////////// - -constexpr int MaxGuidStringSize = 4 * 8 + 3; + +//////////////////////////////////////////////////////////////////////////////// + +constexpr int MaxGuidStringSize = 4 * 8 + 3; char* WriteGuidToBuffer(char* ptr, TGuid value); //////////////////////////////////////////////////////////////////////////////// -} // namespace NYT - -//////////////////////////////////////////////////////////////////////////////// - -Y_DECLARE_PODTYPE(NYT::TGuid); - -//! A hasher for TGuid. -template <> +} // namespace NYT + +//////////////////////////////////////////////////////////////////////////////// + +Y_DECLARE_PODTYPE(NYT::TGuid); + +//! A hasher for TGuid. +template <> struct THash<NYT::TGuid> -{ - size_t operator()(const NYT::TGuid& guid) const; -}; - -//////////////////////////////////////////////////////////////////////////////// - -#define GUID_INL_H_ -#include "guid-inl.h" -#undef GUID_INL_H_ +{ + size_t operator()(const NYT::TGuid& guid) const; +}; + +//////////////////////////////////////////////////////////////////////////////// + +#define GUID_INL_H_ +#include "guid-inl.h" +#undef GUID_INL_H_ diff --git a/library/cpp/yt/misc/hash-inl.h b/library/cpp/yt/misc/hash-inl.h index 46eeefe620..0b8873c2d3 100644 --- a/library/cpp/yt/misc/hash-inl.h +++ b/library/cpp/yt/misc/hash-inl.h @@ -1,47 +1,47 @@ -#ifndef HASH_INL_H_ -#error "Direct inclusion of this file is not allowed, include hash.h" +#ifndef HASH_INL_H_ +#error "Direct inclusion of this file is not allowed, include hash.h" // For the sake of sane code completion. #include "hash.h" -#endif - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -inline void HashCombine(size_t& h, size_t k) -{ - static_assert(sizeof(size_t) == 8, "size_t must be 64 bit."); - - const size_t m = 0xc6a4a7935bd1e995ULL; - const int r = 47; - - k *= m; - k ^= k >> r; - k *= m; - - h ^= k; - h *= m; -} - -template <class T> -void HashCombine(size_t& h, const T& k) -{ - HashCombine(h, THash<T>()(k)); -} - -//////////////////////////////////////////////////////////////////////////////// - -template <class TElement, class TUnderlying> -TRandomizedHash<TElement, TUnderlying>::TRandomizedHash() - : Seed_(RandomNumber<size_t>()) -{ } - -template <class TElement, class TUnderlying> -size_t TRandomizedHash<TElement, TUnderlying>::operator ()(const TElement& element) const -{ - return Underlying_(element) + Seed_; -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +#endif + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +inline void HashCombine(size_t& h, size_t k) +{ + static_assert(sizeof(size_t) == 8, "size_t must be 64 bit."); + + const size_t m = 0xc6a4a7935bd1e995ULL; + const int r = 47; + + k *= m; + k ^= k >> r; + k *= m; + + h ^= k; + h *= m; +} + +template <class T> +void HashCombine(size_t& h, const T& k) +{ + HashCombine(h, THash<T>()(k)); +} + +//////////////////////////////////////////////////////////////////////////////// + +template <class TElement, class TUnderlying> +TRandomizedHash<TElement, TUnderlying>::TRandomizedHash() + : Seed_(RandomNumber<size_t>()) +{ } + +template <class TElement, class TUnderlying> +size_t TRandomizedHash<TElement, TUnderlying>::operator ()(const TElement& element) const +{ + return Underlying_(element) + Seed_; +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/library/cpp/yt/misc/hash.h b/library/cpp/yt/misc/hash.h index 2fecf89506..ec03732999 100644 --- a/library/cpp/yt/misc/hash.h +++ b/library/cpp/yt/misc/hash.h @@ -1,31 +1,31 @@ -#pragma once - -#include <util/generic/hash.h> - +#pragma once + +#include <util/generic/hash.h> + #include <util/random/random.h> -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -//! Updates #h with #k. -//! Cf. |boost::hash_combine|. -void HashCombine(size_t& h, size_t k); - -//! Updates #h with the hash of #k. -//! Cf. |boost::hash_combine|. -template <class T> -void HashCombine(size_t& h, const T& k); - -//////////////////////////////////////////////////////////////////////////////// +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +//! Updates #h with #k. +//! Cf. |boost::hash_combine|. +void HashCombine(size_t& h, size_t k); + +//! Updates #h with the hash of #k. +//! Cf. |boost::hash_combine|. +template <class T> +void HashCombine(size_t& h, const T& k); + +//////////////////////////////////////////////////////////////////////////////// //! Provides a hasher that randomizes the results of another one. template <class TElement, class TUnderlying = ::THash<TElement>> class TRandomizedHash { public: - TRandomizedHash(); - size_t operator () (const TElement& element) const; + TRandomizedHash(); + size_t operator () (const TElement& element) const; private: size_t Seed_; @@ -33,10 +33,10 @@ private: }; -//////////////////////////////////////////////////////////////////////////////// - +//////////////////////////////////////////////////////////////////////////////// + } // namespace NYT -#define HASH_INL_H_ -#include "hash-inl.h" -#undef HASH_INL_H_ +#define HASH_INL_H_ +#include "hash-inl.h" +#undef HASH_INL_H_ diff --git a/library/cpp/yt/misc/port.h b/library/cpp/yt/misc/port.h index b24ac50995..894a485b5a 100644 --- a/library/cpp/yt/misc/port.h +++ b/library/cpp/yt/misc/port.h @@ -2,69 +2,69 @@ #include <util/system/platform.h> -// Check platform bitness. +// Check platform bitness. #if !defined(_64_) - #error YT requires 64-bit platform -#endif - -// This define enables tracking of reference-counted objects to provide -// various insightful information on memory usage and object creation patterns. -#define YT_ENABLE_REF_COUNTED_TRACKING - + #error YT requires 64-bit platform +#endif + +// This define enables tracking of reference-counted objects to provide +// various insightful information on memory usage and object creation patterns. +#define YT_ENABLE_REF_COUNTED_TRACKING + // This define enables logging with TRACE level. You can still disable trace logging // for particular TU by discarding this macro identifier. #define YT_ENABLE_TRACE_LOGGING -#ifndef NDEBUG - // This define enables thread affinity check -- a user-defined verification ensuring - // that some functions are called from particular threads. - #define YT_ENABLE_THREAD_AFFINITY_CHECK - - // This define enables tracking of BIND callbacks location. - #define YT_ENABLE_BIND_LOCATION_TRACKING - - // This define enables checking that all required protobuf fields are present - // during serialization. - #define YT_VALIDATE_REQUIRED_PROTO_FIELDS - - // Detects deadlocks caused by recursive acquisitions of (non-recursive) spin locks. - #define YT_ENABLE_SPIN_LOCK_OWNERSHIP_TRACKING -#endif - -// Configure SSE usage. +#ifndef NDEBUG + // This define enables thread affinity check -- a user-defined verification ensuring + // that some functions are called from particular threads. + #define YT_ENABLE_THREAD_AFFINITY_CHECK + + // This define enables tracking of BIND callbacks location. + #define YT_ENABLE_BIND_LOCATION_TRACKING + + // This define enables checking that all required protobuf fields are present + // during serialization. + #define YT_VALIDATE_REQUIRED_PROTO_FIELDS + + // Detects deadlocks caused by recursive acquisitions of (non-recursive) spin locks. + #define YT_ENABLE_SPIN_LOCK_OWNERSHIP_TRACKING +#endif + +// Configure SSE usage. #ifdef SSE42_ENABLED - #define YT_USE_SSE42 -#endif - -#ifdef _win_ - // Someone above has defined this by including one of Windows headers. - #undef GetMessage - #undef Yield - - // For protobuf-generated files: - // C4125: decimal digit terminates octal escape sequence - #pragma warning (disable: 4125) - // C4505: unreferenced local function has been removed - #pragma warning (disable : 4505) - // C4121: alignment of a member was sensitive to packing - #pragma warning (disable: 4121) - // C4503: decorated name length exceeded, name was truncated - #pragma warning (disable : 4503) - // C4714: function marked as __forceinline not inlined - #pragma warning (disable: 4714) - // C4250: inherits via dominance - #pragma warning (disable: 4250) -#endif - -#if defined(__GNUC__) || defined(__clang__) - #define PER_THREAD __thread - #define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) + #define YT_USE_SSE42 +#endif + +#ifdef _win_ + // Someone above has defined this by including one of Windows headers. + #undef GetMessage + #undef Yield + + // For protobuf-generated files: + // C4125: decimal digit terminates octal escape sequence + #pragma warning (disable: 4125) + // C4505: unreferenced local function has been removed + #pragma warning (disable : 4505) + // C4121: alignment of a member was sensitive to packing + #pragma warning (disable: 4121) + // C4503: decorated name length exceeded, name was truncated + #pragma warning (disable : 4503) + // C4714: function marked as __forceinline not inlined + #pragma warning (disable: 4714) + // C4250: inherits via dominance + #pragma warning (disable: 4250) +#endif + +#if defined(__GNUC__) || defined(__clang__) + #define PER_THREAD __thread + #define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) // Prevent GCC from throwing out functions in release builds. #define ATTRIBUTE_USED __attribute__((used)) -#elif defined(_MSC_VER) - #define PER_THREAD __declspec(thread) - #define ATTRIBUTE_NO_SANITIZE_ADDRESS +#elif defined(_MSC_VER) + #define PER_THREAD __declspec(thread) + #define ATTRIBUTE_NO_SANITIZE_ADDRESS #define ATTRIBUTE_USED -#else - #error Unsupported compiler -#endif +#else + #error Unsupported compiler +#endif diff --git a/library/cpp/yt/misc/preprocessor-gen.h b/library/cpp/yt/misc/preprocessor-gen.h index b809941bcd..912216330a 100644 --- a/library/cpp/yt/misc/preprocessor-gen.h +++ b/library/cpp/yt/misc/preprocessor-gen.h @@ -1,125 +1,125 @@ -#pragma once - -// WARNING: This file was auto-generated. -// Please, consider incorporating any changes into the generator. - -// Generated on Wed Dec 9 14:20:20 2015. - - -/*! - \internal -*/ - -#ifndef PREPROCESSOR_GEN_H_ -#error "Direct inclusion of this file is not allowed, include preprocessor.h" -// For the sake of sane code completion. -#include "preprocessor.h" -#endif -#undef PREPROCESSOR_GEN_H_ - -//////////////////////////////////////////////////////////////////////////////// -#define PP_COUNT_IMPL(...) PP_CONCAT(PP_COUNT_CONST_, \ - PP_COUNT_IMPL_0 __VA_ARGS__) -#define PP_COUNT_CONST_PP_COUNT_IMPL_0 0 -#define PP_COUNT_CONST_PP_COUNT_IMPL_1 1 -#define PP_COUNT_CONST_PP_COUNT_IMPL_2 2 -#define PP_COUNT_CONST_PP_COUNT_IMPL_3 3 -#define PP_COUNT_CONST_PP_COUNT_IMPL_4 4 -#define PP_COUNT_CONST_PP_COUNT_IMPL_5 5 -#define PP_COUNT_CONST_PP_COUNT_IMPL_6 6 -#define PP_COUNT_CONST_PP_COUNT_IMPL_7 7 -#define PP_COUNT_CONST_PP_COUNT_IMPL_8 8 -#define PP_COUNT_CONST_PP_COUNT_IMPL_9 9 -#define PP_COUNT_CONST_PP_COUNT_IMPL_10 10 -#define PP_COUNT_CONST_PP_COUNT_IMPL_11 11 -#define PP_COUNT_CONST_PP_COUNT_IMPL_12 12 -#define PP_COUNT_CONST_PP_COUNT_IMPL_13 13 -#define PP_COUNT_CONST_PP_COUNT_IMPL_14 14 -#define PP_COUNT_CONST_PP_COUNT_IMPL_15 15 -#define PP_COUNT_CONST_PP_COUNT_IMPL_16 16 -#define PP_COUNT_CONST_PP_COUNT_IMPL_17 17 -#define PP_COUNT_CONST_PP_COUNT_IMPL_18 18 -#define PP_COUNT_CONST_PP_COUNT_IMPL_19 19 -#define PP_COUNT_CONST_PP_COUNT_IMPL_20 20 -#define PP_COUNT_CONST_PP_COUNT_IMPL_21 21 -#define PP_COUNT_CONST_PP_COUNT_IMPL_22 22 -#define PP_COUNT_CONST_PP_COUNT_IMPL_23 23 -#define PP_COUNT_CONST_PP_COUNT_IMPL_24 24 -#define PP_COUNT_CONST_PP_COUNT_IMPL_25 25 -#define PP_COUNT_CONST_PP_COUNT_IMPL_26 26 -#define PP_COUNT_CONST_PP_COUNT_IMPL_27 27 -#define PP_COUNT_CONST_PP_COUNT_IMPL_28 28 -#define PP_COUNT_CONST_PP_COUNT_IMPL_29 29 -#define PP_COUNT_CONST_PP_COUNT_IMPL_30 30 -#define PP_COUNT_CONST_PP_COUNT_IMPL_31 31 -#define PP_COUNT_CONST_PP_COUNT_IMPL_32 32 -#define PP_COUNT_CONST_PP_COUNT_IMPL_33 33 -#define PP_COUNT_CONST_PP_COUNT_IMPL_34 34 -#define PP_COUNT_CONST_PP_COUNT_IMPL_35 35 -#define PP_COUNT_CONST_PP_COUNT_IMPL_36 36 -#define PP_COUNT_CONST_PP_COUNT_IMPL_37 37 -#define PP_COUNT_CONST_PP_COUNT_IMPL_38 38 -#define PP_COUNT_CONST_PP_COUNT_IMPL_39 39 -#define PP_COUNT_CONST_PP_COUNT_IMPL_40 40 -#define PP_COUNT_CONST_PP_COUNT_IMPL_41 41 -#define PP_COUNT_CONST_PP_COUNT_IMPL_42 42 -#define PP_COUNT_CONST_PP_COUNT_IMPL_43 43 -#define PP_COUNT_CONST_PP_COUNT_IMPL_44 44 -#define PP_COUNT_CONST_PP_COUNT_IMPL_45 45 -#define PP_COUNT_CONST_PP_COUNT_IMPL_46 46 -#define PP_COUNT_CONST_PP_COUNT_IMPL_47 47 -#define PP_COUNT_CONST_PP_COUNT_IMPL_48 48 -#define PP_COUNT_CONST_PP_COUNT_IMPL_49 49 -#define PP_COUNT_CONST_PP_COUNT_IMPL_50 50 -#define PP_COUNT_CONST_PP_COUNT_IMPL_51 51 -#define PP_COUNT_CONST_PP_COUNT_IMPL_52 52 -#define PP_COUNT_CONST_PP_COUNT_IMPL_53 53 -#define PP_COUNT_CONST_PP_COUNT_IMPL_54 54 -#define PP_COUNT_CONST_PP_COUNT_IMPL_55 55 -#define PP_COUNT_CONST_PP_COUNT_IMPL_56 56 -#define PP_COUNT_CONST_PP_COUNT_IMPL_57 57 -#define PP_COUNT_CONST_PP_COUNT_IMPL_58 58 -#define PP_COUNT_CONST_PP_COUNT_IMPL_59 59 -#define PP_COUNT_CONST_PP_COUNT_IMPL_60 60 -#define PP_COUNT_CONST_PP_COUNT_IMPL_61 61 -#define PP_COUNT_CONST_PP_COUNT_IMPL_62 62 -#define PP_COUNT_CONST_PP_COUNT_IMPL_63 63 -#define PP_COUNT_CONST_PP_COUNT_IMPL_64 64 -#define PP_COUNT_CONST_PP_COUNT_IMPL_65 65 -#define PP_COUNT_CONST_PP_COUNT_IMPL_66 66 -#define PP_COUNT_CONST_PP_COUNT_IMPL_67 67 -#define PP_COUNT_CONST_PP_COUNT_IMPL_68 68 -#define PP_COUNT_CONST_PP_COUNT_IMPL_69 69 -#define PP_COUNT_CONST_PP_COUNT_IMPL_70 70 -#define PP_COUNT_CONST_PP_COUNT_IMPL_71 71 -#define PP_COUNT_CONST_PP_COUNT_IMPL_72 72 -#define PP_COUNT_CONST_PP_COUNT_IMPL_73 73 -#define PP_COUNT_CONST_PP_COUNT_IMPL_74 74 -#define PP_COUNT_CONST_PP_COUNT_IMPL_75 75 -#define PP_COUNT_CONST_PP_COUNT_IMPL_76 76 -#define PP_COUNT_CONST_PP_COUNT_IMPL_77 77 -#define PP_COUNT_CONST_PP_COUNT_IMPL_78 78 -#define PP_COUNT_CONST_PP_COUNT_IMPL_79 79 -#define PP_COUNT_CONST_PP_COUNT_IMPL_80 80 -#define PP_COUNT_CONST_PP_COUNT_IMPL_81 81 -#define PP_COUNT_CONST_PP_COUNT_IMPL_82 82 -#define PP_COUNT_CONST_PP_COUNT_IMPL_83 83 -#define PP_COUNT_CONST_PP_COUNT_IMPL_84 84 -#define PP_COUNT_CONST_PP_COUNT_IMPL_85 85 -#define PP_COUNT_CONST_PP_COUNT_IMPL_86 86 -#define PP_COUNT_CONST_PP_COUNT_IMPL_87 87 -#define PP_COUNT_CONST_PP_COUNT_IMPL_88 88 -#define PP_COUNT_CONST_PP_COUNT_IMPL_89 89 -#define PP_COUNT_CONST_PP_COUNT_IMPL_90 90 -#define PP_COUNT_CONST_PP_COUNT_IMPL_91 91 -#define PP_COUNT_CONST_PP_COUNT_IMPL_92 92 -#define PP_COUNT_CONST_PP_COUNT_IMPL_93 93 -#define PP_COUNT_CONST_PP_COUNT_IMPL_94 94 -#define PP_COUNT_CONST_PP_COUNT_IMPL_95 95 -#define PP_COUNT_CONST_PP_COUNT_IMPL_96 96 -#define PP_COUNT_CONST_PP_COUNT_IMPL_97 97 -#define PP_COUNT_CONST_PP_COUNT_IMPL_98 98 -#define PP_COUNT_CONST_PP_COUNT_IMPL_99 99 +#pragma once + +// WARNING: This file was auto-generated. +// Please, consider incorporating any changes into the generator. + +// Generated on Wed Dec 9 14:20:20 2015. + + +/*! + \internal +*/ + +#ifndef PREPROCESSOR_GEN_H_ +#error "Direct inclusion of this file is not allowed, include preprocessor.h" +// For the sake of sane code completion. +#include "preprocessor.h" +#endif +#undef PREPROCESSOR_GEN_H_ + +//////////////////////////////////////////////////////////////////////////////// +#define PP_COUNT_IMPL(...) PP_CONCAT(PP_COUNT_CONST_, \ + PP_COUNT_IMPL_0 __VA_ARGS__) +#define PP_COUNT_CONST_PP_COUNT_IMPL_0 0 +#define PP_COUNT_CONST_PP_COUNT_IMPL_1 1 +#define PP_COUNT_CONST_PP_COUNT_IMPL_2 2 +#define PP_COUNT_CONST_PP_COUNT_IMPL_3 3 +#define PP_COUNT_CONST_PP_COUNT_IMPL_4 4 +#define PP_COUNT_CONST_PP_COUNT_IMPL_5 5 +#define PP_COUNT_CONST_PP_COUNT_IMPL_6 6 +#define PP_COUNT_CONST_PP_COUNT_IMPL_7 7 +#define PP_COUNT_CONST_PP_COUNT_IMPL_8 8 +#define PP_COUNT_CONST_PP_COUNT_IMPL_9 9 +#define PP_COUNT_CONST_PP_COUNT_IMPL_10 10 +#define PP_COUNT_CONST_PP_COUNT_IMPL_11 11 +#define PP_COUNT_CONST_PP_COUNT_IMPL_12 12 +#define PP_COUNT_CONST_PP_COUNT_IMPL_13 13 +#define PP_COUNT_CONST_PP_COUNT_IMPL_14 14 +#define PP_COUNT_CONST_PP_COUNT_IMPL_15 15 +#define PP_COUNT_CONST_PP_COUNT_IMPL_16 16 +#define PP_COUNT_CONST_PP_COUNT_IMPL_17 17 +#define PP_COUNT_CONST_PP_COUNT_IMPL_18 18 +#define PP_COUNT_CONST_PP_COUNT_IMPL_19 19 +#define PP_COUNT_CONST_PP_COUNT_IMPL_20 20 +#define PP_COUNT_CONST_PP_COUNT_IMPL_21 21 +#define PP_COUNT_CONST_PP_COUNT_IMPL_22 22 +#define PP_COUNT_CONST_PP_COUNT_IMPL_23 23 +#define PP_COUNT_CONST_PP_COUNT_IMPL_24 24 +#define PP_COUNT_CONST_PP_COUNT_IMPL_25 25 +#define PP_COUNT_CONST_PP_COUNT_IMPL_26 26 +#define PP_COUNT_CONST_PP_COUNT_IMPL_27 27 +#define PP_COUNT_CONST_PP_COUNT_IMPL_28 28 +#define PP_COUNT_CONST_PP_COUNT_IMPL_29 29 +#define PP_COUNT_CONST_PP_COUNT_IMPL_30 30 +#define PP_COUNT_CONST_PP_COUNT_IMPL_31 31 +#define PP_COUNT_CONST_PP_COUNT_IMPL_32 32 +#define PP_COUNT_CONST_PP_COUNT_IMPL_33 33 +#define PP_COUNT_CONST_PP_COUNT_IMPL_34 34 +#define PP_COUNT_CONST_PP_COUNT_IMPL_35 35 +#define PP_COUNT_CONST_PP_COUNT_IMPL_36 36 +#define PP_COUNT_CONST_PP_COUNT_IMPL_37 37 +#define PP_COUNT_CONST_PP_COUNT_IMPL_38 38 +#define PP_COUNT_CONST_PP_COUNT_IMPL_39 39 +#define PP_COUNT_CONST_PP_COUNT_IMPL_40 40 +#define PP_COUNT_CONST_PP_COUNT_IMPL_41 41 +#define PP_COUNT_CONST_PP_COUNT_IMPL_42 42 +#define PP_COUNT_CONST_PP_COUNT_IMPL_43 43 +#define PP_COUNT_CONST_PP_COUNT_IMPL_44 44 +#define PP_COUNT_CONST_PP_COUNT_IMPL_45 45 +#define PP_COUNT_CONST_PP_COUNT_IMPL_46 46 +#define PP_COUNT_CONST_PP_COUNT_IMPL_47 47 +#define PP_COUNT_CONST_PP_COUNT_IMPL_48 48 +#define PP_COUNT_CONST_PP_COUNT_IMPL_49 49 +#define PP_COUNT_CONST_PP_COUNT_IMPL_50 50 +#define PP_COUNT_CONST_PP_COUNT_IMPL_51 51 +#define PP_COUNT_CONST_PP_COUNT_IMPL_52 52 +#define PP_COUNT_CONST_PP_COUNT_IMPL_53 53 +#define PP_COUNT_CONST_PP_COUNT_IMPL_54 54 +#define PP_COUNT_CONST_PP_COUNT_IMPL_55 55 +#define PP_COUNT_CONST_PP_COUNT_IMPL_56 56 +#define PP_COUNT_CONST_PP_COUNT_IMPL_57 57 +#define PP_COUNT_CONST_PP_COUNT_IMPL_58 58 +#define PP_COUNT_CONST_PP_COUNT_IMPL_59 59 +#define PP_COUNT_CONST_PP_COUNT_IMPL_60 60 +#define PP_COUNT_CONST_PP_COUNT_IMPL_61 61 +#define PP_COUNT_CONST_PP_COUNT_IMPL_62 62 +#define PP_COUNT_CONST_PP_COUNT_IMPL_63 63 +#define PP_COUNT_CONST_PP_COUNT_IMPL_64 64 +#define PP_COUNT_CONST_PP_COUNT_IMPL_65 65 +#define PP_COUNT_CONST_PP_COUNT_IMPL_66 66 +#define PP_COUNT_CONST_PP_COUNT_IMPL_67 67 +#define PP_COUNT_CONST_PP_COUNT_IMPL_68 68 +#define PP_COUNT_CONST_PP_COUNT_IMPL_69 69 +#define PP_COUNT_CONST_PP_COUNT_IMPL_70 70 +#define PP_COUNT_CONST_PP_COUNT_IMPL_71 71 +#define PP_COUNT_CONST_PP_COUNT_IMPL_72 72 +#define PP_COUNT_CONST_PP_COUNT_IMPL_73 73 +#define PP_COUNT_CONST_PP_COUNT_IMPL_74 74 +#define PP_COUNT_CONST_PP_COUNT_IMPL_75 75 +#define PP_COUNT_CONST_PP_COUNT_IMPL_76 76 +#define PP_COUNT_CONST_PP_COUNT_IMPL_77 77 +#define PP_COUNT_CONST_PP_COUNT_IMPL_78 78 +#define PP_COUNT_CONST_PP_COUNT_IMPL_79 79 +#define PP_COUNT_CONST_PP_COUNT_IMPL_80 80 +#define PP_COUNT_CONST_PP_COUNT_IMPL_81 81 +#define PP_COUNT_CONST_PP_COUNT_IMPL_82 82 +#define PP_COUNT_CONST_PP_COUNT_IMPL_83 83 +#define PP_COUNT_CONST_PP_COUNT_IMPL_84 84 +#define PP_COUNT_CONST_PP_COUNT_IMPL_85 85 +#define PP_COUNT_CONST_PP_COUNT_IMPL_86 86 +#define PP_COUNT_CONST_PP_COUNT_IMPL_87 87 +#define PP_COUNT_CONST_PP_COUNT_IMPL_88 88 +#define PP_COUNT_CONST_PP_COUNT_IMPL_89 89 +#define PP_COUNT_CONST_PP_COUNT_IMPL_90 90 +#define PP_COUNT_CONST_PP_COUNT_IMPL_91 91 +#define PP_COUNT_CONST_PP_COUNT_IMPL_92 92 +#define PP_COUNT_CONST_PP_COUNT_IMPL_93 93 +#define PP_COUNT_CONST_PP_COUNT_IMPL_94 94 +#define PP_COUNT_CONST_PP_COUNT_IMPL_95 95 +#define PP_COUNT_CONST_PP_COUNT_IMPL_96 96 +#define PP_COUNT_CONST_PP_COUNT_IMPL_97 97 +#define PP_COUNT_CONST_PP_COUNT_IMPL_98 98 +#define PP_COUNT_CONST_PP_COUNT_IMPL_99 99 #define PP_COUNT_CONST_PP_COUNT_IMPL_100 100 #define PP_COUNT_CONST_PP_COUNT_IMPL_101 101 #define PP_COUNT_CONST_PP_COUNT_IMPL_102 102 @@ -220,106 +220,106 @@ #define PP_COUNT_CONST_PP_COUNT_IMPL_197 197 #define PP_COUNT_CONST_PP_COUNT_IMPL_198 198 #define PP_COUNT_CONST_PP_COUNT_IMPL_199 199 -#define PP_COUNT_IMPL_0(_) PP_COUNT_IMPL_1 -#define PP_COUNT_IMPL_1(_) PP_COUNT_IMPL_2 -#define PP_COUNT_IMPL_2(_) PP_COUNT_IMPL_3 -#define PP_COUNT_IMPL_3(_) PP_COUNT_IMPL_4 -#define PP_COUNT_IMPL_4(_) PP_COUNT_IMPL_5 -#define PP_COUNT_IMPL_5(_) PP_COUNT_IMPL_6 -#define PP_COUNT_IMPL_6(_) PP_COUNT_IMPL_7 -#define PP_COUNT_IMPL_7(_) PP_COUNT_IMPL_8 -#define PP_COUNT_IMPL_8(_) PP_COUNT_IMPL_9 -#define PP_COUNT_IMPL_9(_) PP_COUNT_IMPL_10 -#define PP_COUNT_IMPL_10(_) PP_COUNT_IMPL_11 -#define PP_COUNT_IMPL_11(_) PP_COUNT_IMPL_12 -#define PP_COUNT_IMPL_12(_) PP_COUNT_IMPL_13 -#define PP_COUNT_IMPL_13(_) PP_COUNT_IMPL_14 -#define PP_COUNT_IMPL_14(_) PP_COUNT_IMPL_15 -#define PP_COUNT_IMPL_15(_) PP_COUNT_IMPL_16 -#define PP_COUNT_IMPL_16(_) PP_COUNT_IMPL_17 -#define PP_COUNT_IMPL_17(_) PP_COUNT_IMPL_18 -#define PP_COUNT_IMPL_18(_) PP_COUNT_IMPL_19 -#define PP_COUNT_IMPL_19(_) PP_COUNT_IMPL_20 -#define PP_COUNT_IMPL_20(_) PP_COUNT_IMPL_21 -#define PP_COUNT_IMPL_21(_) PP_COUNT_IMPL_22 -#define PP_COUNT_IMPL_22(_) PP_COUNT_IMPL_23 -#define PP_COUNT_IMPL_23(_) PP_COUNT_IMPL_24 -#define PP_COUNT_IMPL_24(_) PP_COUNT_IMPL_25 -#define PP_COUNT_IMPL_25(_) PP_COUNT_IMPL_26 -#define PP_COUNT_IMPL_26(_) PP_COUNT_IMPL_27 -#define PP_COUNT_IMPL_27(_) PP_COUNT_IMPL_28 -#define PP_COUNT_IMPL_28(_) PP_COUNT_IMPL_29 -#define PP_COUNT_IMPL_29(_) PP_COUNT_IMPL_30 -#define PP_COUNT_IMPL_30(_) PP_COUNT_IMPL_31 -#define PP_COUNT_IMPL_31(_) PP_COUNT_IMPL_32 -#define PP_COUNT_IMPL_32(_) PP_COUNT_IMPL_33 -#define PP_COUNT_IMPL_33(_) PP_COUNT_IMPL_34 -#define PP_COUNT_IMPL_34(_) PP_COUNT_IMPL_35 -#define PP_COUNT_IMPL_35(_) PP_COUNT_IMPL_36 -#define PP_COUNT_IMPL_36(_) PP_COUNT_IMPL_37 -#define PP_COUNT_IMPL_37(_) PP_COUNT_IMPL_38 -#define PP_COUNT_IMPL_38(_) PP_COUNT_IMPL_39 -#define PP_COUNT_IMPL_39(_) PP_COUNT_IMPL_40 -#define PP_COUNT_IMPL_40(_) PP_COUNT_IMPL_41 -#define PP_COUNT_IMPL_41(_) PP_COUNT_IMPL_42 -#define PP_COUNT_IMPL_42(_) PP_COUNT_IMPL_43 -#define PP_COUNT_IMPL_43(_) PP_COUNT_IMPL_44 -#define PP_COUNT_IMPL_44(_) PP_COUNT_IMPL_45 -#define PP_COUNT_IMPL_45(_) PP_COUNT_IMPL_46 -#define PP_COUNT_IMPL_46(_) PP_COUNT_IMPL_47 -#define PP_COUNT_IMPL_47(_) PP_COUNT_IMPL_48 -#define PP_COUNT_IMPL_48(_) PP_COUNT_IMPL_49 -#define PP_COUNT_IMPL_49(_) PP_COUNT_IMPL_50 -#define PP_COUNT_IMPL_50(_) PP_COUNT_IMPL_51 -#define PP_COUNT_IMPL_51(_) PP_COUNT_IMPL_52 -#define PP_COUNT_IMPL_52(_) PP_COUNT_IMPL_53 -#define PP_COUNT_IMPL_53(_) PP_COUNT_IMPL_54 -#define PP_COUNT_IMPL_54(_) PP_COUNT_IMPL_55 -#define PP_COUNT_IMPL_55(_) PP_COUNT_IMPL_56 -#define PP_COUNT_IMPL_56(_) PP_COUNT_IMPL_57 -#define PP_COUNT_IMPL_57(_) PP_COUNT_IMPL_58 -#define PP_COUNT_IMPL_58(_) PP_COUNT_IMPL_59 -#define PP_COUNT_IMPL_59(_) PP_COUNT_IMPL_60 -#define PP_COUNT_IMPL_60(_) PP_COUNT_IMPL_61 -#define PP_COUNT_IMPL_61(_) PP_COUNT_IMPL_62 -#define PP_COUNT_IMPL_62(_) PP_COUNT_IMPL_63 -#define PP_COUNT_IMPL_63(_) PP_COUNT_IMPL_64 -#define PP_COUNT_IMPL_64(_) PP_COUNT_IMPL_65 -#define PP_COUNT_IMPL_65(_) PP_COUNT_IMPL_66 -#define PP_COUNT_IMPL_66(_) PP_COUNT_IMPL_67 -#define PP_COUNT_IMPL_67(_) PP_COUNT_IMPL_68 -#define PP_COUNT_IMPL_68(_) PP_COUNT_IMPL_69 -#define PP_COUNT_IMPL_69(_) PP_COUNT_IMPL_70 -#define PP_COUNT_IMPL_70(_) PP_COUNT_IMPL_71 -#define PP_COUNT_IMPL_71(_) PP_COUNT_IMPL_72 -#define PP_COUNT_IMPL_72(_) PP_COUNT_IMPL_73 -#define PP_COUNT_IMPL_73(_) PP_COUNT_IMPL_74 -#define PP_COUNT_IMPL_74(_) PP_COUNT_IMPL_75 -#define PP_COUNT_IMPL_75(_) PP_COUNT_IMPL_76 -#define PP_COUNT_IMPL_76(_) PP_COUNT_IMPL_77 -#define PP_COUNT_IMPL_77(_) PP_COUNT_IMPL_78 -#define PP_COUNT_IMPL_78(_) PP_COUNT_IMPL_79 -#define PP_COUNT_IMPL_79(_) PP_COUNT_IMPL_80 -#define PP_COUNT_IMPL_80(_) PP_COUNT_IMPL_81 -#define PP_COUNT_IMPL_81(_) PP_COUNT_IMPL_82 -#define PP_COUNT_IMPL_82(_) PP_COUNT_IMPL_83 -#define PP_COUNT_IMPL_83(_) PP_COUNT_IMPL_84 -#define PP_COUNT_IMPL_84(_) PP_COUNT_IMPL_85 -#define PP_COUNT_IMPL_85(_) PP_COUNT_IMPL_86 -#define PP_COUNT_IMPL_86(_) PP_COUNT_IMPL_87 -#define PP_COUNT_IMPL_87(_) PP_COUNT_IMPL_88 -#define PP_COUNT_IMPL_88(_) PP_COUNT_IMPL_89 -#define PP_COUNT_IMPL_89(_) PP_COUNT_IMPL_90 -#define PP_COUNT_IMPL_90(_) PP_COUNT_IMPL_91 -#define PP_COUNT_IMPL_91(_) PP_COUNT_IMPL_92 -#define PP_COUNT_IMPL_92(_) PP_COUNT_IMPL_93 -#define PP_COUNT_IMPL_93(_) PP_COUNT_IMPL_94 -#define PP_COUNT_IMPL_94(_) PP_COUNT_IMPL_95 -#define PP_COUNT_IMPL_95(_) PP_COUNT_IMPL_96 -#define PP_COUNT_IMPL_96(_) PP_COUNT_IMPL_97 -#define PP_COUNT_IMPL_97(_) PP_COUNT_IMPL_98 -#define PP_COUNT_IMPL_98(_) PP_COUNT_IMPL_99 -#define PP_COUNT_IMPL_99(_) PP_COUNT_IMPL_100 +#define PP_COUNT_IMPL_0(_) PP_COUNT_IMPL_1 +#define PP_COUNT_IMPL_1(_) PP_COUNT_IMPL_2 +#define PP_COUNT_IMPL_2(_) PP_COUNT_IMPL_3 +#define PP_COUNT_IMPL_3(_) PP_COUNT_IMPL_4 +#define PP_COUNT_IMPL_4(_) PP_COUNT_IMPL_5 +#define PP_COUNT_IMPL_5(_) PP_COUNT_IMPL_6 +#define PP_COUNT_IMPL_6(_) PP_COUNT_IMPL_7 +#define PP_COUNT_IMPL_7(_) PP_COUNT_IMPL_8 +#define PP_COUNT_IMPL_8(_) PP_COUNT_IMPL_9 +#define PP_COUNT_IMPL_9(_) PP_COUNT_IMPL_10 +#define PP_COUNT_IMPL_10(_) PP_COUNT_IMPL_11 +#define PP_COUNT_IMPL_11(_) PP_COUNT_IMPL_12 +#define PP_COUNT_IMPL_12(_) PP_COUNT_IMPL_13 +#define PP_COUNT_IMPL_13(_) PP_COUNT_IMPL_14 +#define PP_COUNT_IMPL_14(_) PP_COUNT_IMPL_15 +#define PP_COUNT_IMPL_15(_) PP_COUNT_IMPL_16 +#define PP_COUNT_IMPL_16(_) PP_COUNT_IMPL_17 +#define PP_COUNT_IMPL_17(_) PP_COUNT_IMPL_18 +#define PP_COUNT_IMPL_18(_) PP_COUNT_IMPL_19 +#define PP_COUNT_IMPL_19(_) PP_COUNT_IMPL_20 +#define PP_COUNT_IMPL_20(_) PP_COUNT_IMPL_21 +#define PP_COUNT_IMPL_21(_) PP_COUNT_IMPL_22 +#define PP_COUNT_IMPL_22(_) PP_COUNT_IMPL_23 +#define PP_COUNT_IMPL_23(_) PP_COUNT_IMPL_24 +#define PP_COUNT_IMPL_24(_) PP_COUNT_IMPL_25 +#define PP_COUNT_IMPL_25(_) PP_COUNT_IMPL_26 +#define PP_COUNT_IMPL_26(_) PP_COUNT_IMPL_27 +#define PP_COUNT_IMPL_27(_) PP_COUNT_IMPL_28 +#define PP_COUNT_IMPL_28(_) PP_COUNT_IMPL_29 +#define PP_COUNT_IMPL_29(_) PP_COUNT_IMPL_30 +#define PP_COUNT_IMPL_30(_) PP_COUNT_IMPL_31 +#define PP_COUNT_IMPL_31(_) PP_COUNT_IMPL_32 +#define PP_COUNT_IMPL_32(_) PP_COUNT_IMPL_33 +#define PP_COUNT_IMPL_33(_) PP_COUNT_IMPL_34 +#define PP_COUNT_IMPL_34(_) PP_COUNT_IMPL_35 +#define PP_COUNT_IMPL_35(_) PP_COUNT_IMPL_36 +#define PP_COUNT_IMPL_36(_) PP_COUNT_IMPL_37 +#define PP_COUNT_IMPL_37(_) PP_COUNT_IMPL_38 +#define PP_COUNT_IMPL_38(_) PP_COUNT_IMPL_39 +#define PP_COUNT_IMPL_39(_) PP_COUNT_IMPL_40 +#define PP_COUNT_IMPL_40(_) PP_COUNT_IMPL_41 +#define PP_COUNT_IMPL_41(_) PP_COUNT_IMPL_42 +#define PP_COUNT_IMPL_42(_) PP_COUNT_IMPL_43 +#define PP_COUNT_IMPL_43(_) PP_COUNT_IMPL_44 +#define PP_COUNT_IMPL_44(_) PP_COUNT_IMPL_45 +#define PP_COUNT_IMPL_45(_) PP_COUNT_IMPL_46 +#define PP_COUNT_IMPL_46(_) PP_COUNT_IMPL_47 +#define PP_COUNT_IMPL_47(_) PP_COUNT_IMPL_48 +#define PP_COUNT_IMPL_48(_) PP_COUNT_IMPL_49 +#define PP_COUNT_IMPL_49(_) PP_COUNT_IMPL_50 +#define PP_COUNT_IMPL_50(_) PP_COUNT_IMPL_51 +#define PP_COUNT_IMPL_51(_) PP_COUNT_IMPL_52 +#define PP_COUNT_IMPL_52(_) PP_COUNT_IMPL_53 +#define PP_COUNT_IMPL_53(_) PP_COUNT_IMPL_54 +#define PP_COUNT_IMPL_54(_) PP_COUNT_IMPL_55 +#define PP_COUNT_IMPL_55(_) PP_COUNT_IMPL_56 +#define PP_COUNT_IMPL_56(_) PP_COUNT_IMPL_57 +#define PP_COUNT_IMPL_57(_) PP_COUNT_IMPL_58 +#define PP_COUNT_IMPL_58(_) PP_COUNT_IMPL_59 +#define PP_COUNT_IMPL_59(_) PP_COUNT_IMPL_60 +#define PP_COUNT_IMPL_60(_) PP_COUNT_IMPL_61 +#define PP_COUNT_IMPL_61(_) PP_COUNT_IMPL_62 +#define PP_COUNT_IMPL_62(_) PP_COUNT_IMPL_63 +#define PP_COUNT_IMPL_63(_) PP_COUNT_IMPL_64 +#define PP_COUNT_IMPL_64(_) PP_COUNT_IMPL_65 +#define PP_COUNT_IMPL_65(_) PP_COUNT_IMPL_66 +#define PP_COUNT_IMPL_66(_) PP_COUNT_IMPL_67 +#define PP_COUNT_IMPL_67(_) PP_COUNT_IMPL_68 +#define PP_COUNT_IMPL_68(_) PP_COUNT_IMPL_69 +#define PP_COUNT_IMPL_69(_) PP_COUNT_IMPL_70 +#define PP_COUNT_IMPL_70(_) PP_COUNT_IMPL_71 +#define PP_COUNT_IMPL_71(_) PP_COUNT_IMPL_72 +#define PP_COUNT_IMPL_72(_) PP_COUNT_IMPL_73 +#define PP_COUNT_IMPL_73(_) PP_COUNT_IMPL_74 +#define PP_COUNT_IMPL_74(_) PP_COUNT_IMPL_75 +#define PP_COUNT_IMPL_75(_) PP_COUNT_IMPL_76 +#define PP_COUNT_IMPL_76(_) PP_COUNT_IMPL_77 +#define PP_COUNT_IMPL_77(_) PP_COUNT_IMPL_78 +#define PP_COUNT_IMPL_78(_) PP_COUNT_IMPL_79 +#define PP_COUNT_IMPL_79(_) PP_COUNT_IMPL_80 +#define PP_COUNT_IMPL_80(_) PP_COUNT_IMPL_81 +#define PP_COUNT_IMPL_81(_) PP_COUNT_IMPL_82 +#define PP_COUNT_IMPL_82(_) PP_COUNT_IMPL_83 +#define PP_COUNT_IMPL_83(_) PP_COUNT_IMPL_84 +#define PP_COUNT_IMPL_84(_) PP_COUNT_IMPL_85 +#define PP_COUNT_IMPL_85(_) PP_COUNT_IMPL_86 +#define PP_COUNT_IMPL_86(_) PP_COUNT_IMPL_87 +#define PP_COUNT_IMPL_87(_) PP_COUNT_IMPL_88 +#define PP_COUNT_IMPL_88(_) PP_COUNT_IMPL_89 +#define PP_COUNT_IMPL_89(_) PP_COUNT_IMPL_90 +#define PP_COUNT_IMPL_90(_) PP_COUNT_IMPL_91 +#define PP_COUNT_IMPL_91(_) PP_COUNT_IMPL_92 +#define PP_COUNT_IMPL_92(_) PP_COUNT_IMPL_93 +#define PP_COUNT_IMPL_93(_) PP_COUNT_IMPL_94 +#define PP_COUNT_IMPL_94(_) PP_COUNT_IMPL_95 +#define PP_COUNT_IMPL_95(_) PP_COUNT_IMPL_96 +#define PP_COUNT_IMPL_96(_) PP_COUNT_IMPL_97 +#define PP_COUNT_IMPL_97(_) PP_COUNT_IMPL_98 +#define PP_COUNT_IMPL_98(_) PP_COUNT_IMPL_99 +#define PP_COUNT_IMPL_99(_) PP_COUNT_IMPL_100 #define PP_COUNT_IMPL_100(_) PP_COUNT_IMPL_101 #define PP_COUNT_IMPL_101(_) PP_COUNT_IMPL_102 #define PP_COUNT_IMPL_102(_) PP_COUNT_IMPL_103 @@ -420,110 +420,110 @@ #define PP_COUNT_IMPL_197(_) PP_COUNT_IMPL_198 #define PP_COUNT_IMPL_198(_) PP_COUNT_IMPL_199 #define PP_COUNT_IMPL_199(_) PP_COUNT_IMPL_200 - -//////////////////////////////////////////////////////////////////////////////// -#define PP_KILL_IMPL(seq, index) PP_CONCAT(PP_KILL_IMPL_, index) seq -#define PP_KILL_IMPL_0 -#define PP_KILL_IMPL_1(_) PP_KILL_IMPL_0 -#define PP_KILL_IMPL_2(_) PP_KILL_IMPL_1 -#define PP_KILL_IMPL_3(_) PP_KILL_IMPL_2 -#define PP_KILL_IMPL_4(_) PP_KILL_IMPL_3 -#define PP_KILL_IMPL_5(_) PP_KILL_IMPL_4 -#define PP_KILL_IMPL_6(_) PP_KILL_IMPL_5 -#define PP_KILL_IMPL_7(_) PP_KILL_IMPL_6 -#define PP_KILL_IMPL_8(_) PP_KILL_IMPL_7 -#define PP_KILL_IMPL_9(_) PP_KILL_IMPL_8 -#define PP_KILL_IMPL_10(_) PP_KILL_IMPL_9 -#define PP_KILL_IMPL_11(_) PP_KILL_IMPL_10 -#define PP_KILL_IMPL_12(_) PP_KILL_IMPL_11 -#define PP_KILL_IMPL_13(_) PP_KILL_IMPL_12 -#define PP_KILL_IMPL_14(_) PP_KILL_IMPL_13 -#define PP_KILL_IMPL_15(_) PP_KILL_IMPL_14 -#define PP_KILL_IMPL_16(_) PP_KILL_IMPL_15 -#define PP_KILL_IMPL_17(_) PP_KILL_IMPL_16 -#define PP_KILL_IMPL_18(_) PP_KILL_IMPL_17 -#define PP_KILL_IMPL_19(_) PP_KILL_IMPL_18 -#define PP_KILL_IMPL_20(_) PP_KILL_IMPL_19 -#define PP_KILL_IMPL_21(_) PP_KILL_IMPL_20 -#define PP_KILL_IMPL_22(_) PP_KILL_IMPL_21 -#define PP_KILL_IMPL_23(_) PP_KILL_IMPL_22 -#define PP_KILL_IMPL_24(_) PP_KILL_IMPL_23 -#define PP_KILL_IMPL_25(_) PP_KILL_IMPL_24 -#define PP_KILL_IMPL_26(_) PP_KILL_IMPL_25 -#define PP_KILL_IMPL_27(_) PP_KILL_IMPL_26 -#define PP_KILL_IMPL_28(_) PP_KILL_IMPL_27 -#define PP_KILL_IMPL_29(_) PP_KILL_IMPL_28 -#define PP_KILL_IMPL_30(_) PP_KILL_IMPL_29 -#define PP_KILL_IMPL_31(_) PP_KILL_IMPL_30 -#define PP_KILL_IMPL_32(_) PP_KILL_IMPL_31 -#define PP_KILL_IMPL_33(_) PP_KILL_IMPL_32 -#define PP_KILL_IMPL_34(_) PP_KILL_IMPL_33 -#define PP_KILL_IMPL_35(_) PP_KILL_IMPL_34 -#define PP_KILL_IMPL_36(_) PP_KILL_IMPL_35 -#define PP_KILL_IMPL_37(_) PP_KILL_IMPL_36 -#define PP_KILL_IMPL_38(_) PP_KILL_IMPL_37 -#define PP_KILL_IMPL_39(_) PP_KILL_IMPL_38 -#define PP_KILL_IMPL_40(_) PP_KILL_IMPL_39 -#define PP_KILL_IMPL_41(_) PP_KILL_IMPL_40 -#define PP_KILL_IMPL_42(_) PP_KILL_IMPL_41 -#define PP_KILL_IMPL_43(_) PP_KILL_IMPL_42 -#define PP_KILL_IMPL_44(_) PP_KILL_IMPL_43 -#define PP_KILL_IMPL_45(_) PP_KILL_IMPL_44 -#define PP_KILL_IMPL_46(_) PP_KILL_IMPL_45 -#define PP_KILL_IMPL_47(_) PP_KILL_IMPL_46 -#define PP_KILL_IMPL_48(_) PP_KILL_IMPL_47 -#define PP_KILL_IMPL_49(_) PP_KILL_IMPL_48 -#define PP_KILL_IMPL_50(_) PP_KILL_IMPL_49 -#define PP_KILL_IMPL_51(_) PP_KILL_IMPL_50 -#define PP_KILL_IMPL_52(_) PP_KILL_IMPL_51 -#define PP_KILL_IMPL_53(_) PP_KILL_IMPL_52 -#define PP_KILL_IMPL_54(_) PP_KILL_IMPL_53 -#define PP_KILL_IMPL_55(_) PP_KILL_IMPL_54 -#define PP_KILL_IMPL_56(_) PP_KILL_IMPL_55 -#define PP_KILL_IMPL_57(_) PP_KILL_IMPL_56 -#define PP_KILL_IMPL_58(_) PP_KILL_IMPL_57 -#define PP_KILL_IMPL_59(_) PP_KILL_IMPL_58 -#define PP_KILL_IMPL_60(_) PP_KILL_IMPL_59 -#define PP_KILL_IMPL_61(_) PP_KILL_IMPL_60 -#define PP_KILL_IMPL_62(_) PP_KILL_IMPL_61 -#define PP_KILL_IMPL_63(_) PP_KILL_IMPL_62 -#define PP_KILL_IMPL_64(_) PP_KILL_IMPL_63 -#define PP_KILL_IMPL_65(_) PP_KILL_IMPL_64 -#define PP_KILL_IMPL_66(_) PP_KILL_IMPL_65 -#define PP_KILL_IMPL_67(_) PP_KILL_IMPL_66 -#define PP_KILL_IMPL_68(_) PP_KILL_IMPL_67 -#define PP_KILL_IMPL_69(_) PP_KILL_IMPL_68 -#define PP_KILL_IMPL_70(_) PP_KILL_IMPL_69 -#define PP_KILL_IMPL_71(_) PP_KILL_IMPL_70 -#define PP_KILL_IMPL_72(_) PP_KILL_IMPL_71 -#define PP_KILL_IMPL_73(_) PP_KILL_IMPL_72 -#define PP_KILL_IMPL_74(_) PP_KILL_IMPL_73 -#define PP_KILL_IMPL_75(_) PP_KILL_IMPL_74 -#define PP_KILL_IMPL_76(_) PP_KILL_IMPL_75 -#define PP_KILL_IMPL_77(_) PP_KILL_IMPL_76 -#define PP_KILL_IMPL_78(_) PP_KILL_IMPL_77 -#define PP_KILL_IMPL_79(_) PP_KILL_IMPL_78 -#define PP_KILL_IMPL_80(_) PP_KILL_IMPL_79 -#define PP_KILL_IMPL_81(_) PP_KILL_IMPL_80 -#define PP_KILL_IMPL_82(_) PP_KILL_IMPL_81 -#define PP_KILL_IMPL_83(_) PP_KILL_IMPL_82 -#define PP_KILL_IMPL_84(_) PP_KILL_IMPL_83 -#define PP_KILL_IMPL_85(_) PP_KILL_IMPL_84 -#define PP_KILL_IMPL_86(_) PP_KILL_IMPL_85 -#define PP_KILL_IMPL_87(_) PP_KILL_IMPL_86 -#define PP_KILL_IMPL_88(_) PP_KILL_IMPL_87 -#define PP_KILL_IMPL_89(_) PP_KILL_IMPL_88 -#define PP_KILL_IMPL_90(_) PP_KILL_IMPL_89 -#define PP_KILL_IMPL_91(_) PP_KILL_IMPL_90 -#define PP_KILL_IMPL_92(_) PP_KILL_IMPL_91 -#define PP_KILL_IMPL_93(_) PP_KILL_IMPL_92 -#define PP_KILL_IMPL_94(_) PP_KILL_IMPL_93 -#define PP_KILL_IMPL_95(_) PP_KILL_IMPL_94 -#define PP_KILL_IMPL_96(_) PP_KILL_IMPL_95 -#define PP_KILL_IMPL_97(_) PP_KILL_IMPL_96 -#define PP_KILL_IMPL_98(_) PP_KILL_IMPL_97 -#define PP_KILL_IMPL_99(_) PP_KILL_IMPL_98 -#define PP_KILL_IMPL_100(_) PP_KILL_IMPL_99 + +//////////////////////////////////////////////////////////////////////////////// +#define PP_KILL_IMPL(seq, index) PP_CONCAT(PP_KILL_IMPL_, index) seq +#define PP_KILL_IMPL_0 +#define PP_KILL_IMPL_1(_) PP_KILL_IMPL_0 +#define PP_KILL_IMPL_2(_) PP_KILL_IMPL_1 +#define PP_KILL_IMPL_3(_) PP_KILL_IMPL_2 +#define PP_KILL_IMPL_4(_) PP_KILL_IMPL_3 +#define PP_KILL_IMPL_5(_) PP_KILL_IMPL_4 +#define PP_KILL_IMPL_6(_) PP_KILL_IMPL_5 +#define PP_KILL_IMPL_7(_) PP_KILL_IMPL_6 +#define PP_KILL_IMPL_8(_) PP_KILL_IMPL_7 +#define PP_KILL_IMPL_9(_) PP_KILL_IMPL_8 +#define PP_KILL_IMPL_10(_) PP_KILL_IMPL_9 +#define PP_KILL_IMPL_11(_) PP_KILL_IMPL_10 +#define PP_KILL_IMPL_12(_) PP_KILL_IMPL_11 +#define PP_KILL_IMPL_13(_) PP_KILL_IMPL_12 +#define PP_KILL_IMPL_14(_) PP_KILL_IMPL_13 +#define PP_KILL_IMPL_15(_) PP_KILL_IMPL_14 +#define PP_KILL_IMPL_16(_) PP_KILL_IMPL_15 +#define PP_KILL_IMPL_17(_) PP_KILL_IMPL_16 +#define PP_KILL_IMPL_18(_) PP_KILL_IMPL_17 +#define PP_KILL_IMPL_19(_) PP_KILL_IMPL_18 +#define PP_KILL_IMPL_20(_) PP_KILL_IMPL_19 +#define PP_KILL_IMPL_21(_) PP_KILL_IMPL_20 +#define PP_KILL_IMPL_22(_) PP_KILL_IMPL_21 +#define PP_KILL_IMPL_23(_) PP_KILL_IMPL_22 +#define PP_KILL_IMPL_24(_) PP_KILL_IMPL_23 +#define PP_KILL_IMPL_25(_) PP_KILL_IMPL_24 +#define PP_KILL_IMPL_26(_) PP_KILL_IMPL_25 +#define PP_KILL_IMPL_27(_) PP_KILL_IMPL_26 +#define PP_KILL_IMPL_28(_) PP_KILL_IMPL_27 +#define PP_KILL_IMPL_29(_) PP_KILL_IMPL_28 +#define PP_KILL_IMPL_30(_) PP_KILL_IMPL_29 +#define PP_KILL_IMPL_31(_) PP_KILL_IMPL_30 +#define PP_KILL_IMPL_32(_) PP_KILL_IMPL_31 +#define PP_KILL_IMPL_33(_) PP_KILL_IMPL_32 +#define PP_KILL_IMPL_34(_) PP_KILL_IMPL_33 +#define PP_KILL_IMPL_35(_) PP_KILL_IMPL_34 +#define PP_KILL_IMPL_36(_) PP_KILL_IMPL_35 +#define PP_KILL_IMPL_37(_) PP_KILL_IMPL_36 +#define PP_KILL_IMPL_38(_) PP_KILL_IMPL_37 +#define PP_KILL_IMPL_39(_) PP_KILL_IMPL_38 +#define PP_KILL_IMPL_40(_) PP_KILL_IMPL_39 +#define PP_KILL_IMPL_41(_) PP_KILL_IMPL_40 +#define PP_KILL_IMPL_42(_) PP_KILL_IMPL_41 +#define PP_KILL_IMPL_43(_) PP_KILL_IMPL_42 +#define PP_KILL_IMPL_44(_) PP_KILL_IMPL_43 +#define PP_KILL_IMPL_45(_) PP_KILL_IMPL_44 +#define PP_KILL_IMPL_46(_) PP_KILL_IMPL_45 +#define PP_KILL_IMPL_47(_) PP_KILL_IMPL_46 +#define PP_KILL_IMPL_48(_) PP_KILL_IMPL_47 +#define PP_KILL_IMPL_49(_) PP_KILL_IMPL_48 +#define PP_KILL_IMPL_50(_) PP_KILL_IMPL_49 +#define PP_KILL_IMPL_51(_) PP_KILL_IMPL_50 +#define PP_KILL_IMPL_52(_) PP_KILL_IMPL_51 +#define PP_KILL_IMPL_53(_) PP_KILL_IMPL_52 +#define PP_KILL_IMPL_54(_) PP_KILL_IMPL_53 +#define PP_KILL_IMPL_55(_) PP_KILL_IMPL_54 +#define PP_KILL_IMPL_56(_) PP_KILL_IMPL_55 +#define PP_KILL_IMPL_57(_) PP_KILL_IMPL_56 +#define PP_KILL_IMPL_58(_) PP_KILL_IMPL_57 +#define PP_KILL_IMPL_59(_) PP_KILL_IMPL_58 +#define PP_KILL_IMPL_60(_) PP_KILL_IMPL_59 +#define PP_KILL_IMPL_61(_) PP_KILL_IMPL_60 +#define PP_KILL_IMPL_62(_) PP_KILL_IMPL_61 +#define PP_KILL_IMPL_63(_) PP_KILL_IMPL_62 +#define PP_KILL_IMPL_64(_) PP_KILL_IMPL_63 +#define PP_KILL_IMPL_65(_) PP_KILL_IMPL_64 +#define PP_KILL_IMPL_66(_) PP_KILL_IMPL_65 +#define PP_KILL_IMPL_67(_) PP_KILL_IMPL_66 +#define PP_KILL_IMPL_68(_) PP_KILL_IMPL_67 +#define PP_KILL_IMPL_69(_) PP_KILL_IMPL_68 +#define PP_KILL_IMPL_70(_) PP_KILL_IMPL_69 +#define PP_KILL_IMPL_71(_) PP_KILL_IMPL_70 +#define PP_KILL_IMPL_72(_) PP_KILL_IMPL_71 +#define PP_KILL_IMPL_73(_) PP_KILL_IMPL_72 +#define PP_KILL_IMPL_74(_) PP_KILL_IMPL_73 +#define PP_KILL_IMPL_75(_) PP_KILL_IMPL_74 +#define PP_KILL_IMPL_76(_) PP_KILL_IMPL_75 +#define PP_KILL_IMPL_77(_) PP_KILL_IMPL_76 +#define PP_KILL_IMPL_78(_) PP_KILL_IMPL_77 +#define PP_KILL_IMPL_79(_) PP_KILL_IMPL_78 +#define PP_KILL_IMPL_80(_) PP_KILL_IMPL_79 +#define PP_KILL_IMPL_81(_) PP_KILL_IMPL_80 +#define PP_KILL_IMPL_82(_) PP_KILL_IMPL_81 +#define PP_KILL_IMPL_83(_) PP_KILL_IMPL_82 +#define PP_KILL_IMPL_84(_) PP_KILL_IMPL_83 +#define PP_KILL_IMPL_85(_) PP_KILL_IMPL_84 +#define PP_KILL_IMPL_86(_) PP_KILL_IMPL_85 +#define PP_KILL_IMPL_87(_) PP_KILL_IMPL_86 +#define PP_KILL_IMPL_88(_) PP_KILL_IMPL_87 +#define PP_KILL_IMPL_89(_) PP_KILL_IMPL_88 +#define PP_KILL_IMPL_90(_) PP_KILL_IMPL_89 +#define PP_KILL_IMPL_91(_) PP_KILL_IMPL_90 +#define PP_KILL_IMPL_92(_) PP_KILL_IMPL_91 +#define PP_KILL_IMPL_93(_) PP_KILL_IMPL_92 +#define PP_KILL_IMPL_94(_) PP_KILL_IMPL_93 +#define PP_KILL_IMPL_95(_) PP_KILL_IMPL_94 +#define PP_KILL_IMPL_96(_) PP_KILL_IMPL_95 +#define PP_KILL_IMPL_97(_) PP_KILL_IMPL_96 +#define PP_KILL_IMPL_98(_) PP_KILL_IMPL_97 +#define PP_KILL_IMPL_99(_) PP_KILL_IMPL_98 +#define PP_KILL_IMPL_100(_) PP_KILL_IMPL_99 #define PP_KILL_IMPL_101(_) PP_KILL_IMPL_100 #define PP_KILL_IMPL_102(_) PP_KILL_IMPL_101 #define PP_KILL_IMPL_103(_) PP_KILL_IMPL_102 @@ -624,114 +624,114 @@ #define PP_KILL_IMPL_198(_) PP_KILL_IMPL_197 #define PP_KILL_IMPL_199(_) PP_KILL_IMPL_198 #define PP_KILL_IMPL_200(_) PP_KILL_IMPL_199 - -//////////////////////////////////////////////////////////////////////////////// -#define PP_ELEMENT_IMPL(seq, \ - index) PP_ELEMENT_IMPL_A((PP_CONCAT(PP_ELEMENT_IMPL_, index) seq)) -#define PP_ELEMENT_IMPL_A(x) PP_ELEMENT_IMPL_C(PP_ELEMENT_IMPL_B x) -#define PP_ELEMENT_IMPL_B(x, _) x -#define PP_ELEMENT_IMPL_C(x) x -#define PP_ELEMENT_IMPL_0(x) x, PP_NIL -#define PP_ELEMENT_IMPL_1(_) PP_ELEMENT_IMPL_0 -#define PP_ELEMENT_IMPL_2(_) PP_ELEMENT_IMPL_1 -#define PP_ELEMENT_IMPL_3(_) PP_ELEMENT_IMPL_2 -#define PP_ELEMENT_IMPL_4(_) PP_ELEMENT_IMPL_3 -#define PP_ELEMENT_IMPL_5(_) PP_ELEMENT_IMPL_4 -#define PP_ELEMENT_IMPL_6(_) PP_ELEMENT_IMPL_5 -#define PP_ELEMENT_IMPL_7(_) PP_ELEMENT_IMPL_6 -#define PP_ELEMENT_IMPL_8(_) PP_ELEMENT_IMPL_7 -#define PP_ELEMENT_IMPL_9(_) PP_ELEMENT_IMPL_8 -#define PP_ELEMENT_IMPL_10(_) PP_ELEMENT_IMPL_9 -#define PP_ELEMENT_IMPL_11(_) PP_ELEMENT_IMPL_10 -#define PP_ELEMENT_IMPL_12(_) PP_ELEMENT_IMPL_11 -#define PP_ELEMENT_IMPL_13(_) PP_ELEMENT_IMPL_12 -#define PP_ELEMENT_IMPL_14(_) PP_ELEMENT_IMPL_13 -#define PP_ELEMENT_IMPL_15(_) PP_ELEMENT_IMPL_14 -#define PP_ELEMENT_IMPL_16(_) PP_ELEMENT_IMPL_15 -#define PP_ELEMENT_IMPL_17(_) PP_ELEMENT_IMPL_16 -#define PP_ELEMENT_IMPL_18(_) PP_ELEMENT_IMPL_17 -#define PP_ELEMENT_IMPL_19(_) PP_ELEMENT_IMPL_18 -#define PP_ELEMENT_IMPL_20(_) PP_ELEMENT_IMPL_19 -#define PP_ELEMENT_IMPL_21(_) PP_ELEMENT_IMPL_20 -#define PP_ELEMENT_IMPL_22(_) PP_ELEMENT_IMPL_21 -#define PP_ELEMENT_IMPL_23(_) PP_ELEMENT_IMPL_22 -#define PP_ELEMENT_IMPL_24(_) PP_ELEMENT_IMPL_23 -#define PP_ELEMENT_IMPL_25(_) PP_ELEMENT_IMPL_24 -#define PP_ELEMENT_IMPL_26(_) PP_ELEMENT_IMPL_25 -#define PP_ELEMENT_IMPL_27(_) PP_ELEMENT_IMPL_26 -#define PP_ELEMENT_IMPL_28(_) PP_ELEMENT_IMPL_27 -#define PP_ELEMENT_IMPL_29(_) PP_ELEMENT_IMPL_28 -#define PP_ELEMENT_IMPL_30(_) PP_ELEMENT_IMPL_29 -#define PP_ELEMENT_IMPL_31(_) PP_ELEMENT_IMPL_30 -#define PP_ELEMENT_IMPL_32(_) PP_ELEMENT_IMPL_31 -#define PP_ELEMENT_IMPL_33(_) PP_ELEMENT_IMPL_32 -#define PP_ELEMENT_IMPL_34(_) PP_ELEMENT_IMPL_33 -#define PP_ELEMENT_IMPL_35(_) PP_ELEMENT_IMPL_34 -#define PP_ELEMENT_IMPL_36(_) PP_ELEMENT_IMPL_35 -#define PP_ELEMENT_IMPL_37(_) PP_ELEMENT_IMPL_36 -#define PP_ELEMENT_IMPL_38(_) PP_ELEMENT_IMPL_37 -#define PP_ELEMENT_IMPL_39(_) PP_ELEMENT_IMPL_38 -#define PP_ELEMENT_IMPL_40(_) PP_ELEMENT_IMPL_39 -#define PP_ELEMENT_IMPL_41(_) PP_ELEMENT_IMPL_40 -#define PP_ELEMENT_IMPL_42(_) PP_ELEMENT_IMPL_41 -#define PP_ELEMENT_IMPL_43(_) PP_ELEMENT_IMPL_42 -#define PP_ELEMENT_IMPL_44(_) PP_ELEMENT_IMPL_43 -#define PP_ELEMENT_IMPL_45(_) PP_ELEMENT_IMPL_44 -#define PP_ELEMENT_IMPL_46(_) PP_ELEMENT_IMPL_45 -#define PP_ELEMENT_IMPL_47(_) PP_ELEMENT_IMPL_46 -#define PP_ELEMENT_IMPL_48(_) PP_ELEMENT_IMPL_47 -#define PP_ELEMENT_IMPL_49(_) PP_ELEMENT_IMPL_48 -#define PP_ELEMENT_IMPL_50(_) PP_ELEMENT_IMPL_49 -#define PP_ELEMENT_IMPL_51(_) PP_ELEMENT_IMPL_50 -#define PP_ELEMENT_IMPL_52(_) PP_ELEMENT_IMPL_51 -#define PP_ELEMENT_IMPL_53(_) PP_ELEMENT_IMPL_52 -#define PP_ELEMENT_IMPL_54(_) PP_ELEMENT_IMPL_53 -#define PP_ELEMENT_IMPL_55(_) PP_ELEMENT_IMPL_54 -#define PP_ELEMENT_IMPL_56(_) PP_ELEMENT_IMPL_55 -#define PP_ELEMENT_IMPL_57(_) PP_ELEMENT_IMPL_56 -#define PP_ELEMENT_IMPL_58(_) PP_ELEMENT_IMPL_57 -#define PP_ELEMENT_IMPL_59(_) PP_ELEMENT_IMPL_58 -#define PP_ELEMENT_IMPL_60(_) PP_ELEMENT_IMPL_59 -#define PP_ELEMENT_IMPL_61(_) PP_ELEMENT_IMPL_60 -#define PP_ELEMENT_IMPL_62(_) PP_ELEMENT_IMPL_61 -#define PP_ELEMENT_IMPL_63(_) PP_ELEMENT_IMPL_62 -#define PP_ELEMENT_IMPL_64(_) PP_ELEMENT_IMPL_63 -#define PP_ELEMENT_IMPL_65(_) PP_ELEMENT_IMPL_64 -#define PP_ELEMENT_IMPL_66(_) PP_ELEMENT_IMPL_65 -#define PP_ELEMENT_IMPL_67(_) PP_ELEMENT_IMPL_66 -#define PP_ELEMENT_IMPL_68(_) PP_ELEMENT_IMPL_67 -#define PP_ELEMENT_IMPL_69(_) PP_ELEMENT_IMPL_68 -#define PP_ELEMENT_IMPL_70(_) PP_ELEMENT_IMPL_69 -#define PP_ELEMENT_IMPL_71(_) PP_ELEMENT_IMPL_70 -#define PP_ELEMENT_IMPL_72(_) PP_ELEMENT_IMPL_71 -#define PP_ELEMENT_IMPL_73(_) PP_ELEMENT_IMPL_72 -#define PP_ELEMENT_IMPL_74(_) PP_ELEMENT_IMPL_73 -#define PP_ELEMENT_IMPL_75(_) PP_ELEMENT_IMPL_74 -#define PP_ELEMENT_IMPL_76(_) PP_ELEMENT_IMPL_75 -#define PP_ELEMENT_IMPL_77(_) PP_ELEMENT_IMPL_76 -#define PP_ELEMENT_IMPL_78(_) PP_ELEMENT_IMPL_77 -#define PP_ELEMENT_IMPL_79(_) PP_ELEMENT_IMPL_78 -#define PP_ELEMENT_IMPL_80(_) PP_ELEMENT_IMPL_79 -#define PP_ELEMENT_IMPL_81(_) PP_ELEMENT_IMPL_80 -#define PP_ELEMENT_IMPL_82(_) PP_ELEMENT_IMPL_81 -#define PP_ELEMENT_IMPL_83(_) PP_ELEMENT_IMPL_82 -#define PP_ELEMENT_IMPL_84(_) PP_ELEMENT_IMPL_83 -#define PP_ELEMENT_IMPL_85(_) PP_ELEMENT_IMPL_84 -#define PP_ELEMENT_IMPL_86(_) PP_ELEMENT_IMPL_85 -#define PP_ELEMENT_IMPL_87(_) PP_ELEMENT_IMPL_86 -#define PP_ELEMENT_IMPL_88(_) PP_ELEMENT_IMPL_87 -#define PP_ELEMENT_IMPL_89(_) PP_ELEMENT_IMPL_88 -#define PP_ELEMENT_IMPL_90(_) PP_ELEMENT_IMPL_89 -#define PP_ELEMENT_IMPL_91(_) PP_ELEMENT_IMPL_90 -#define PP_ELEMENT_IMPL_92(_) PP_ELEMENT_IMPL_91 -#define PP_ELEMENT_IMPL_93(_) PP_ELEMENT_IMPL_92 -#define PP_ELEMENT_IMPL_94(_) PP_ELEMENT_IMPL_93 -#define PP_ELEMENT_IMPL_95(_) PP_ELEMENT_IMPL_94 -#define PP_ELEMENT_IMPL_96(_) PP_ELEMENT_IMPL_95 -#define PP_ELEMENT_IMPL_97(_) PP_ELEMENT_IMPL_96 -#define PP_ELEMENT_IMPL_98(_) PP_ELEMENT_IMPL_97 -#define PP_ELEMENT_IMPL_99(_) PP_ELEMENT_IMPL_98 -#define PP_ELEMENT_IMPL_100(_) PP_ELEMENT_IMPL_99 + +//////////////////////////////////////////////////////////////////////////////// +#define PP_ELEMENT_IMPL(seq, \ + index) PP_ELEMENT_IMPL_A((PP_CONCAT(PP_ELEMENT_IMPL_, index) seq)) +#define PP_ELEMENT_IMPL_A(x) PP_ELEMENT_IMPL_C(PP_ELEMENT_IMPL_B x) +#define PP_ELEMENT_IMPL_B(x, _) x +#define PP_ELEMENT_IMPL_C(x) x +#define PP_ELEMENT_IMPL_0(x) x, PP_NIL +#define PP_ELEMENT_IMPL_1(_) PP_ELEMENT_IMPL_0 +#define PP_ELEMENT_IMPL_2(_) PP_ELEMENT_IMPL_1 +#define PP_ELEMENT_IMPL_3(_) PP_ELEMENT_IMPL_2 +#define PP_ELEMENT_IMPL_4(_) PP_ELEMENT_IMPL_3 +#define PP_ELEMENT_IMPL_5(_) PP_ELEMENT_IMPL_4 +#define PP_ELEMENT_IMPL_6(_) PP_ELEMENT_IMPL_5 +#define PP_ELEMENT_IMPL_7(_) PP_ELEMENT_IMPL_6 +#define PP_ELEMENT_IMPL_8(_) PP_ELEMENT_IMPL_7 +#define PP_ELEMENT_IMPL_9(_) PP_ELEMENT_IMPL_8 +#define PP_ELEMENT_IMPL_10(_) PP_ELEMENT_IMPL_9 +#define PP_ELEMENT_IMPL_11(_) PP_ELEMENT_IMPL_10 +#define PP_ELEMENT_IMPL_12(_) PP_ELEMENT_IMPL_11 +#define PP_ELEMENT_IMPL_13(_) PP_ELEMENT_IMPL_12 +#define PP_ELEMENT_IMPL_14(_) PP_ELEMENT_IMPL_13 +#define PP_ELEMENT_IMPL_15(_) PP_ELEMENT_IMPL_14 +#define PP_ELEMENT_IMPL_16(_) PP_ELEMENT_IMPL_15 +#define PP_ELEMENT_IMPL_17(_) PP_ELEMENT_IMPL_16 +#define PP_ELEMENT_IMPL_18(_) PP_ELEMENT_IMPL_17 +#define PP_ELEMENT_IMPL_19(_) PP_ELEMENT_IMPL_18 +#define PP_ELEMENT_IMPL_20(_) PP_ELEMENT_IMPL_19 +#define PP_ELEMENT_IMPL_21(_) PP_ELEMENT_IMPL_20 +#define PP_ELEMENT_IMPL_22(_) PP_ELEMENT_IMPL_21 +#define PP_ELEMENT_IMPL_23(_) PP_ELEMENT_IMPL_22 +#define PP_ELEMENT_IMPL_24(_) PP_ELEMENT_IMPL_23 +#define PP_ELEMENT_IMPL_25(_) PP_ELEMENT_IMPL_24 +#define PP_ELEMENT_IMPL_26(_) PP_ELEMENT_IMPL_25 +#define PP_ELEMENT_IMPL_27(_) PP_ELEMENT_IMPL_26 +#define PP_ELEMENT_IMPL_28(_) PP_ELEMENT_IMPL_27 +#define PP_ELEMENT_IMPL_29(_) PP_ELEMENT_IMPL_28 +#define PP_ELEMENT_IMPL_30(_) PP_ELEMENT_IMPL_29 +#define PP_ELEMENT_IMPL_31(_) PP_ELEMENT_IMPL_30 +#define PP_ELEMENT_IMPL_32(_) PP_ELEMENT_IMPL_31 +#define PP_ELEMENT_IMPL_33(_) PP_ELEMENT_IMPL_32 +#define PP_ELEMENT_IMPL_34(_) PP_ELEMENT_IMPL_33 +#define PP_ELEMENT_IMPL_35(_) PP_ELEMENT_IMPL_34 +#define PP_ELEMENT_IMPL_36(_) PP_ELEMENT_IMPL_35 +#define PP_ELEMENT_IMPL_37(_) PP_ELEMENT_IMPL_36 +#define PP_ELEMENT_IMPL_38(_) PP_ELEMENT_IMPL_37 +#define PP_ELEMENT_IMPL_39(_) PP_ELEMENT_IMPL_38 +#define PP_ELEMENT_IMPL_40(_) PP_ELEMENT_IMPL_39 +#define PP_ELEMENT_IMPL_41(_) PP_ELEMENT_IMPL_40 +#define PP_ELEMENT_IMPL_42(_) PP_ELEMENT_IMPL_41 +#define PP_ELEMENT_IMPL_43(_) PP_ELEMENT_IMPL_42 +#define PP_ELEMENT_IMPL_44(_) PP_ELEMENT_IMPL_43 +#define PP_ELEMENT_IMPL_45(_) PP_ELEMENT_IMPL_44 +#define PP_ELEMENT_IMPL_46(_) PP_ELEMENT_IMPL_45 +#define PP_ELEMENT_IMPL_47(_) PP_ELEMENT_IMPL_46 +#define PP_ELEMENT_IMPL_48(_) PP_ELEMENT_IMPL_47 +#define PP_ELEMENT_IMPL_49(_) PP_ELEMENT_IMPL_48 +#define PP_ELEMENT_IMPL_50(_) PP_ELEMENT_IMPL_49 +#define PP_ELEMENT_IMPL_51(_) PP_ELEMENT_IMPL_50 +#define PP_ELEMENT_IMPL_52(_) PP_ELEMENT_IMPL_51 +#define PP_ELEMENT_IMPL_53(_) PP_ELEMENT_IMPL_52 +#define PP_ELEMENT_IMPL_54(_) PP_ELEMENT_IMPL_53 +#define PP_ELEMENT_IMPL_55(_) PP_ELEMENT_IMPL_54 +#define PP_ELEMENT_IMPL_56(_) PP_ELEMENT_IMPL_55 +#define PP_ELEMENT_IMPL_57(_) PP_ELEMENT_IMPL_56 +#define PP_ELEMENT_IMPL_58(_) PP_ELEMENT_IMPL_57 +#define PP_ELEMENT_IMPL_59(_) PP_ELEMENT_IMPL_58 +#define PP_ELEMENT_IMPL_60(_) PP_ELEMENT_IMPL_59 +#define PP_ELEMENT_IMPL_61(_) PP_ELEMENT_IMPL_60 +#define PP_ELEMENT_IMPL_62(_) PP_ELEMENT_IMPL_61 +#define PP_ELEMENT_IMPL_63(_) PP_ELEMENT_IMPL_62 +#define PP_ELEMENT_IMPL_64(_) PP_ELEMENT_IMPL_63 +#define PP_ELEMENT_IMPL_65(_) PP_ELEMENT_IMPL_64 +#define PP_ELEMENT_IMPL_66(_) PP_ELEMENT_IMPL_65 +#define PP_ELEMENT_IMPL_67(_) PP_ELEMENT_IMPL_66 +#define PP_ELEMENT_IMPL_68(_) PP_ELEMENT_IMPL_67 +#define PP_ELEMENT_IMPL_69(_) PP_ELEMENT_IMPL_68 +#define PP_ELEMENT_IMPL_70(_) PP_ELEMENT_IMPL_69 +#define PP_ELEMENT_IMPL_71(_) PP_ELEMENT_IMPL_70 +#define PP_ELEMENT_IMPL_72(_) PP_ELEMENT_IMPL_71 +#define PP_ELEMENT_IMPL_73(_) PP_ELEMENT_IMPL_72 +#define PP_ELEMENT_IMPL_74(_) PP_ELEMENT_IMPL_73 +#define PP_ELEMENT_IMPL_75(_) PP_ELEMENT_IMPL_74 +#define PP_ELEMENT_IMPL_76(_) PP_ELEMENT_IMPL_75 +#define PP_ELEMENT_IMPL_77(_) PP_ELEMENT_IMPL_76 +#define PP_ELEMENT_IMPL_78(_) PP_ELEMENT_IMPL_77 +#define PP_ELEMENT_IMPL_79(_) PP_ELEMENT_IMPL_78 +#define PP_ELEMENT_IMPL_80(_) PP_ELEMENT_IMPL_79 +#define PP_ELEMENT_IMPL_81(_) PP_ELEMENT_IMPL_80 +#define PP_ELEMENT_IMPL_82(_) PP_ELEMENT_IMPL_81 +#define PP_ELEMENT_IMPL_83(_) PP_ELEMENT_IMPL_82 +#define PP_ELEMENT_IMPL_84(_) PP_ELEMENT_IMPL_83 +#define PP_ELEMENT_IMPL_85(_) PP_ELEMENT_IMPL_84 +#define PP_ELEMENT_IMPL_86(_) PP_ELEMENT_IMPL_85 +#define PP_ELEMENT_IMPL_87(_) PP_ELEMENT_IMPL_86 +#define PP_ELEMENT_IMPL_88(_) PP_ELEMENT_IMPL_87 +#define PP_ELEMENT_IMPL_89(_) PP_ELEMENT_IMPL_88 +#define PP_ELEMENT_IMPL_90(_) PP_ELEMENT_IMPL_89 +#define PP_ELEMENT_IMPL_91(_) PP_ELEMENT_IMPL_90 +#define PP_ELEMENT_IMPL_92(_) PP_ELEMENT_IMPL_91 +#define PP_ELEMENT_IMPL_93(_) PP_ELEMENT_IMPL_92 +#define PP_ELEMENT_IMPL_94(_) PP_ELEMENT_IMPL_93 +#define PP_ELEMENT_IMPL_95(_) PP_ELEMENT_IMPL_94 +#define PP_ELEMENT_IMPL_96(_) PP_ELEMENT_IMPL_95 +#define PP_ELEMENT_IMPL_97(_) PP_ELEMENT_IMPL_96 +#define PP_ELEMENT_IMPL_98(_) PP_ELEMENT_IMPL_97 +#define PP_ELEMENT_IMPL_99(_) PP_ELEMENT_IMPL_98 +#define PP_ELEMENT_IMPL_100(_) PP_ELEMENT_IMPL_99 #define PP_ELEMENT_IMPL_101(_) PP_ELEMENT_IMPL_100 #define PP_ELEMENT_IMPL_102(_) PP_ELEMENT_IMPL_101 #define PP_ELEMENT_IMPL_103(_) PP_ELEMENT_IMPL_102 @@ -832,217 +832,217 @@ #define PP_ELEMENT_IMPL_198(_) PP_ELEMENT_IMPL_197 #define PP_ELEMENT_IMPL_199(_) PP_ELEMENT_IMPL_198 #define PP_ELEMENT_IMPL_200(_) PP_ELEMENT_IMPL_199 - -//////////////////////////////////////////////////////////////////////////////// -#define PP_HEAD_IMPL(seq) PP_ELEMENT_IMPL(seq, 0) - -//////////////////////////////////////////////////////////////////////////////// -#define PP_TAIL_IMPL(seq) PP_KILL_IMPL(seq, 1) - -//////////////////////////////////////////////////////////////////////////////// -#define PP_FOR_EACH_IMPL(what, seq) PP_CONCAT(PP_FOR_EACH_IMPL_, \ - PP_COUNT(seq))(what, seq) -#define PP_FOR_EACH_IMPL_0(what, seq) -#define PP_FOR_EACH_IMPL_1(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_0(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_2(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_1(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_3(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_2(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_4(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_3(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_5(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_4(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_6(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_5(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_7(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_6(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_8(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_7(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_9(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_8(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_10(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_9(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_11(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_10(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_12(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_11(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_13(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_12(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_14(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_13(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_15(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_14(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_16(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_15(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_17(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_16(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_18(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_17(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_19(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_18(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_20(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_19(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_21(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_20(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_22(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_21(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_23(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_22(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_24(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_23(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_25(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_24(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_26(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_25(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_27(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_26(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_28(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_27(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_29(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_28(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_30(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_29(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_31(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_30(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_32(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_31(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_33(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_32(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_34(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_33(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_35(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_34(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_36(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_35(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_37(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_36(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_38(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_37(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_39(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_38(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_40(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_39(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_41(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_40(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_42(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_41(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_43(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_42(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_44(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_43(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_45(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_44(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_46(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_45(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_47(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_46(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_48(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_47(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_49(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_48(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_50(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_49(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_51(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_50(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_52(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_51(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_53(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_52(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_54(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_53(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_55(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_54(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_56(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_55(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_57(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_56(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_58(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_57(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_59(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_58(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_60(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_59(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_61(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_60(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_62(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_61(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_63(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_62(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_64(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_63(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_65(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_64(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_66(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_65(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_67(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_66(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_68(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_67(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_69(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_68(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_70(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_69(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_71(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_70(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_72(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_71(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_73(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_72(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_74(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_73(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_75(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_74(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_76(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_75(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_77(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_76(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_78(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_77(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_79(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_78(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_80(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_79(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_81(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_80(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_82(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_81(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_83(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_82(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_84(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_83(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_85(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_84(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_86(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_85(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_87(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_86(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_88(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_87(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_89(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_88(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_90(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_89(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_91(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_90(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_92(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_91(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_93(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_92(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_94(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_93(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_95(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_94(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_96(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_95(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_97(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_96(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_98(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_97(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_99(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_98(what, PP_TAIL(seq)) -#define PP_FOR_EACH_IMPL_100(what, \ - seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_99(what, PP_TAIL(seq)) + +//////////////////////////////////////////////////////////////////////////////// +#define PP_HEAD_IMPL(seq) PP_ELEMENT_IMPL(seq, 0) + +//////////////////////////////////////////////////////////////////////////////// +#define PP_TAIL_IMPL(seq) PP_KILL_IMPL(seq, 1) + +//////////////////////////////////////////////////////////////////////////////// +#define PP_FOR_EACH_IMPL(what, seq) PP_CONCAT(PP_FOR_EACH_IMPL_, \ + PP_COUNT(seq))(what, seq) +#define PP_FOR_EACH_IMPL_0(what, seq) +#define PP_FOR_EACH_IMPL_1(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_0(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_2(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_1(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_3(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_2(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_4(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_3(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_5(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_4(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_6(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_5(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_7(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_6(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_8(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_7(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_9(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_8(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_10(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_9(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_11(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_10(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_12(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_11(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_13(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_12(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_14(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_13(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_15(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_14(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_16(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_15(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_17(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_16(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_18(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_17(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_19(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_18(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_20(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_19(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_21(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_20(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_22(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_21(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_23(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_22(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_24(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_23(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_25(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_24(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_26(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_25(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_27(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_26(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_28(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_27(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_29(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_28(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_30(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_29(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_31(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_30(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_32(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_31(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_33(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_32(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_34(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_33(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_35(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_34(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_36(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_35(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_37(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_36(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_38(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_37(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_39(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_38(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_40(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_39(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_41(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_40(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_42(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_41(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_43(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_42(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_44(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_43(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_45(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_44(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_46(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_45(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_47(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_46(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_48(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_47(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_49(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_48(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_50(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_49(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_51(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_50(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_52(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_51(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_53(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_52(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_54(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_53(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_55(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_54(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_56(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_55(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_57(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_56(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_58(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_57(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_59(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_58(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_60(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_59(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_61(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_60(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_62(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_61(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_63(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_62(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_64(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_63(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_65(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_64(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_66(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_65(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_67(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_66(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_68(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_67(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_69(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_68(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_70(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_69(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_71(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_70(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_72(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_71(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_73(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_72(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_74(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_73(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_75(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_74(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_76(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_75(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_77(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_76(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_78(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_77(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_79(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_78(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_80(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_79(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_81(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_80(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_82(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_81(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_83(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_82(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_84(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_83(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_85(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_84(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_86(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_85(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_87(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_86(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_88(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_87(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_89(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_88(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_90(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_89(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_91(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_90(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_92(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_91(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_93(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_92(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_94(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_93(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_95(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_94(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_96(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_95(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_97(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_96(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_98(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_97(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_99(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_98(what, PP_TAIL(seq)) +#define PP_FOR_EACH_IMPL_100(what, \ + seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_99(what, PP_TAIL(seq)) #define PP_FOR_EACH_IMPL_101(what, \ seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_100(what, PP_TAIL(seq)) #define PP_FOR_EACH_IMPL_102(what, \ @@ -1243,7 +1243,7 @@ seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_198(what, PP_TAIL(seq)) #define PP_FOR_EACH_IMPL_200(what, \ seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_199(what, PP_TAIL(seq)) -//////////////////////////////////////////////////////////////////////////////// -/*! - \endinternal -*/ +//////////////////////////////////////////////////////////////////////////////// +/*! + \endinternal +*/ diff --git a/library/cpp/yt/misc/preprocessor-gen.h.pump b/library/cpp/yt/misc/preprocessor-gen.h.pump index 0f178ae37e..7e3517fdd1 100644 --- a/library/cpp/yt/misc/preprocessor-gen.h.pump +++ b/library/cpp/yt/misc/preprocessor-gen.h.pump @@ -1,70 +1,70 @@ -#pragma once - -$$ Please, use Pump to convert this source file to valid C++ header. -$$ Note that lines in this file could be longer than 80 symbols. +#pragma once + +$$ Please, use Pump to convert this source file to valid C++ header. +$$ Note that lines in this file could be longer than 80 symbols. $var n = 199 -$range i 0..n - -/*! - \internal -*/ - -#ifndef PREPROCESSOR_GEN_H_ -#error "Direct inclusion of this file is not allowed, include preprocessor.h" -// For the sake of sane code completion. -#include "preprocessor.h" -#endif -#undef PREPROCESSOR_GEN_H_ - -//////////////////////////////////////////////////////////////////////////////// -#define PP_COUNT_IMPL(...) PP_CONCAT(PP_COUNT_CONST_, PP_COUNT_IMPL_0 __VA_ARGS__) - -$for i [[ -#define PP_COUNT_CONST_PP_COUNT_IMPL_$i $i - -]] - -$for i [[ -#define PP_COUNT_IMPL_$i(_) PP_COUNT_IMPL_$(i+1) - -]] - -//////////////////////////////////////////////////////////////////////////////// -#define PP_KILL_IMPL(seq, index) PP_CONCAT(PP_KILL_IMPL_, index) seq -#define PP_KILL_IMPL_0 - -$for i [[ -#define PP_KILL_IMPL_$(i+1)(_) PP_KILL_IMPL_$i - -]] - -//////////////////////////////////////////////////////////////////////////////// -#define PP_ELEMENT_IMPL(seq, index) PP_ELEMENT_IMPL_A((PP_CONCAT(PP_ELEMENT_IMPL_, index) seq)) -#define PP_ELEMENT_IMPL_A(x) PP_ELEMENT_IMPL_C(PP_ELEMENT_IMPL_B x) -#define PP_ELEMENT_IMPL_B(x, _) x -#define PP_ELEMENT_IMPL_C(x) x -#define PP_ELEMENT_IMPL_0(x) x, PP_NIL - -$for i [[ -#define PP_ELEMENT_IMPL_$(i+1)(_) PP_ELEMENT_IMPL_$i - -]] - -//////////////////////////////////////////////////////////////////////////////// -#define PP_HEAD_IMPL(seq) PP_ELEMENT_IMPL(seq, 0) - -//////////////////////////////////////////////////////////////////////////////// -#define PP_TAIL_IMPL(seq) PP_KILL_IMPL(seq, 1) - -//////////////////////////////////////////////////////////////////////////////// -#define PP_FOR_EACH_IMPL(what, seq) PP_CONCAT(PP_FOR_EACH_IMPL_, PP_COUNT(seq))(what, seq) -#define PP_FOR_EACH_IMPL_0(what, seq) - -$for i [[ -#define PP_FOR_EACH_IMPL_$(i+1)(what, seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_$i(what, PP_TAIL(seq)) - -]] -//////////////////////////////////////////////////////////////////////////////// -/*! - \endinternal -*/ +$range i 0..n + +/*! + \internal +*/ + +#ifndef PREPROCESSOR_GEN_H_ +#error "Direct inclusion of this file is not allowed, include preprocessor.h" +// For the sake of sane code completion. +#include "preprocessor.h" +#endif +#undef PREPROCESSOR_GEN_H_ + +//////////////////////////////////////////////////////////////////////////////// +#define PP_COUNT_IMPL(...) PP_CONCAT(PP_COUNT_CONST_, PP_COUNT_IMPL_0 __VA_ARGS__) + +$for i [[ +#define PP_COUNT_CONST_PP_COUNT_IMPL_$i $i + +]] + +$for i [[ +#define PP_COUNT_IMPL_$i(_) PP_COUNT_IMPL_$(i+1) + +]] + +//////////////////////////////////////////////////////////////////////////////// +#define PP_KILL_IMPL(seq, index) PP_CONCAT(PP_KILL_IMPL_, index) seq +#define PP_KILL_IMPL_0 + +$for i [[ +#define PP_KILL_IMPL_$(i+1)(_) PP_KILL_IMPL_$i + +]] + +//////////////////////////////////////////////////////////////////////////////// +#define PP_ELEMENT_IMPL(seq, index) PP_ELEMENT_IMPL_A((PP_CONCAT(PP_ELEMENT_IMPL_, index) seq)) +#define PP_ELEMENT_IMPL_A(x) PP_ELEMENT_IMPL_C(PP_ELEMENT_IMPL_B x) +#define PP_ELEMENT_IMPL_B(x, _) x +#define PP_ELEMENT_IMPL_C(x) x +#define PP_ELEMENT_IMPL_0(x) x, PP_NIL + +$for i [[ +#define PP_ELEMENT_IMPL_$(i+1)(_) PP_ELEMENT_IMPL_$i + +]] + +//////////////////////////////////////////////////////////////////////////////// +#define PP_HEAD_IMPL(seq) PP_ELEMENT_IMPL(seq, 0) + +//////////////////////////////////////////////////////////////////////////////// +#define PP_TAIL_IMPL(seq) PP_KILL_IMPL(seq, 1) + +//////////////////////////////////////////////////////////////////////////////// +#define PP_FOR_EACH_IMPL(what, seq) PP_CONCAT(PP_FOR_EACH_IMPL_, PP_COUNT(seq))(what, seq) +#define PP_FOR_EACH_IMPL_0(what, seq) + +$for i [[ +#define PP_FOR_EACH_IMPL_$(i+1)(what, seq) what(PP_HEAD(seq)) PP_FOR_EACH_IMPL_$i(what, PP_TAIL(seq)) + +]] +//////////////////////////////////////////////////////////////////////////////// +/*! + \endinternal +*/ diff --git a/library/cpp/yt/misc/preprocessor.h b/library/cpp/yt/misc/preprocessor.h index 9afd3ae902..1372d6534f 100644 --- a/library/cpp/yt/misc/preprocessor.h +++ b/library/cpp/yt/misc/preprocessor.h @@ -1,124 +1,124 @@ -#pragma once - -/*! - * \file preprocesor.h - * \brief Preprocessor metaprogramming macroses - */ - -#if !defined(_MSC_VER) && !defined(__GNUC__) -# error Your compiler is not currently supported. -#endif - -/*! - * \defgroup yt_pp Preprocessor metaprogramming macroses - * \ingroup yt_commons - * - * This is collection of macro definitions for various metaprogramming tasks - * with the preprocessor. - * - * \{ - * - * \page yt_pp_sequences Sequences - * Everything revolves around the concept of a \em sequence. A typical - * sequence is encoded like <tt>(1)(2)(3)...</tt>. Internally this allows - * to apply some macro to the every element in the sequence (see #PP_FOR_EACH). - * - * Note that sequences can be nested, i. e. <tt>((1)(2)(3))(a)(b)(c)</tt> - * - * \page yt_pp_examples Examples - * Please refer to the unit test for an actual example of usage - * (unittests/preprocessor_ut.cpp). - * - */ - -//! Concatenates two tokens. -#define PP_CONCAT(x, y) PP_CONCAT_A(x, y) -//! \cond Implementation -#define PP_CONCAT_A(x, y) PP_CONCAT_B(x, y) -#define PP_CONCAT_B(x, y) x ## y -//! \endcond - -//! Transforms token into the string forcing argument expansion. -#define PP_STRINGIZE(x) PP_STRINGIZE_A(x) -//! \cond Implementation -#define PP_STRINGIZE_A(x) PP_STRINGIZE_B(x) -#define PP_STRINGIZE_B(x) #x -//! \endcond - -//! \cond Implementation -#define PP_LEFT_PARENTHESIS ( -#define PP_RIGHT_PARENTHESIS ) -#define PP_COMMA() , -#define PP_EMPTY() -//! \endcond - -//! Performs (non-lazy) conditional expansion. -/*! - * \param cond Condition; should expands to either \c PP_TRUE or \c PP_FALSE. - * \param _then Expansion result in case when \c cond holds. - * \param _else Expansion result in case when \c cond does not hold. - */ -#define PP_IF(cond, _then, _else) PP_CONCAT(PP_IF_, cond)(_then, _else) -//! \cond Implementation -#define PP_IF_PP_TRUE(x, y) x -#define PP_IF_PP_FALSE(x, y) y -//! \endcond - -//! Tests whether supplied argument can be treated as a sequence -//! (i. e. <tt>()()()...</tt>) -#define PP_IS_SEQUENCE(arg) PP_CONCAT(PP_IS_SEQUENCE_B_, PP_COUNT((PP_NIL PP_IS_SEQUENCE_A arg PP_NIL))) -//! \cond Implementation -#define PP_IS_SEQUENCE_A(_) PP_RIGHT_PARENTHESIS PP_LEFT_PARENTHESIS -#define PP_IS_SEQUENCE_B_1 PP_FALSE -#define PP_IS_SEQUENCE_B_2 PP_TRUE -//! \endcond - -//! Computes the number of elements in the sequence. -#define PP_COUNT(...) PP_COUNT_IMPL(__VA_ARGS__) - -//! Removes first \c n elements from the sequence. -#define PP_KILL(seq, n) PP_KILL_IMPL(seq, n) - -//! Extracts the head of the sequence. -/*! For example, \code PP_HEAD((0)(1)(2)(3)) == 0 \endcode - */ -#define PP_HEAD(...) PP_HEAD_IMPL(__VA_ARGS__) - -//! Extracts the tail of the sequence. -/*! For example, \code PP_TAIL((0)(1)(2)(3)) == (1)(2)(3) \endcode - */ -#define PP_TAIL(...) PP_TAIL_IMPL(__VA_ARGS__) - -//! Extracts the element with the specified index from the sequence. -/*! For example, \code PP_ELEMENT((0)(1)(2)(3), 1) == 1 \endcode - */ -#define PP_ELEMENT(seq, index) PP_ELEMENT_IMPL(seq, index) - -//! Applies the macro to every member of the sequence. -/*! For example, - * \code - * #define MyFunctor(x) +x+ - * PP_FOR_EACH(MyFunctor, (0)(1)(2)(3)) == +0+ +1+ +2+ +3+ - * \encode - */ -#define PP_FOR_EACH(what, seq) PP_FOR_EACH_IMPL(what, seq) - -//! Declares an anonymous variable. -#ifdef __COUNTER__ -#define PP_ANONYMOUS_VARIABLE(str) PP_CONCAT(str, __COUNTER__) -#else -#define PP_ANONYMOUS_VARIABLE(str) PP_CONCAT(str, __LINE__) -#endif - -//! Insert prefix based on presence of additional arguments. -#define PP_ONE_OR_NONE(a, ...) PP_THIRD(a, ## __VA_ARGS__, a) -#define PP_THIRD(a, b, ...) __VA_ARGS__ - -//! \cond Implementation -#define PREPROCESSOR_GEN_H_ -#include "preprocessor-gen.h" -#undef PREPROCESSOR_GEN_H_ -//! \endcond - -/*! \} */ - +#pragma once + +/*! + * \file preprocesor.h + * \brief Preprocessor metaprogramming macroses + */ + +#if !defined(_MSC_VER) && !defined(__GNUC__) +# error Your compiler is not currently supported. +#endif + +/*! + * \defgroup yt_pp Preprocessor metaprogramming macroses + * \ingroup yt_commons + * + * This is collection of macro definitions for various metaprogramming tasks + * with the preprocessor. + * + * \{ + * + * \page yt_pp_sequences Sequences + * Everything revolves around the concept of a \em sequence. A typical + * sequence is encoded like <tt>(1)(2)(3)...</tt>. Internally this allows + * to apply some macro to the every element in the sequence (see #PP_FOR_EACH). + * + * Note that sequences can be nested, i. e. <tt>((1)(2)(3))(a)(b)(c)</tt> + * + * \page yt_pp_examples Examples + * Please refer to the unit test for an actual example of usage + * (unittests/preprocessor_ut.cpp). + * + */ + +//! Concatenates two tokens. +#define PP_CONCAT(x, y) PP_CONCAT_A(x, y) +//! \cond Implementation +#define PP_CONCAT_A(x, y) PP_CONCAT_B(x, y) +#define PP_CONCAT_B(x, y) x ## y +//! \endcond + +//! Transforms token into the string forcing argument expansion. +#define PP_STRINGIZE(x) PP_STRINGIZE_A(x) +//! \cond Implementation +#define PP_STRINGIZE_A(x) PP_STRINGIZE_B(x) +#define PP_STRINGIZE_B(x) #x +//! \endcond + +//! \cond Implementation +#define PP_LEFT_PARENTHESIS ( +#define PP_RIGHT_PARENTHESIS ) +#define PP_COMMA() , +#define PP_EMPTY() +//! \endcond + +//! Performs (non-lazy) conditional expansion. +/*! + * \param cond Condition; should expands to either \c PP_TRUE or \c PP_FALSE. + * \param _then Expansion result in case when \c cond holds. + * \param _else Expansion result in case when \c cond does not hold. + */ +#define PP_IF(cond, _then, _else) PP_CONCAT(PP_IF_, cond)(_then, _else) +//! \cond Implementation +#define PP_IF_PP_TRUE(x, y) x +#define PP_IF_PP_FALSE(x, y) y +//! \endcond + +//! Tests whether supplied argument can be treated as a sequence +//! (i. e. <tt>()()()...</tt>) +#define PP_IS_SEQUENCE(arg) PP_CONCAT(PP_IS_SEQUENCE_B_, PP_COUNT((PP_NIL PP_IS_SEQUENCE_A arg PP_NIL))) +//! \cond Implementation +#define PP_IS_SEQUENCE_A(_) PP_RIGHT_PARENTHESIS PP_LEFT_PARENTHESIS +#define PP_IS_SEQUENCE_B_1 PP_FALSE +#define PP_IS_SEQUENCE_B_2 PP_TRUE +//! \endcond + +//! Computes the number of elements in the sequence. +#define PP_COUNT(...) PP_COUNT_IMPL(__VA_ARGS__) + +//! Removes first \c n elements from the sequence. +#define PP_KILL(seq, n) PP_KILL_IMPL(seq, n) + +//! Extracts the head of the sequence. +/*! For example, \code PP_HEAD((0)(1)(2)(3)) == 0 \endcode + */ +#define PP_HEAD(...) PP_HEAD_IMPL(__VA_ARGS__) + +//! Extracts the tail of the sequence. +/*! For example, \code PP_TAIL((0)(1)(2)(3)) == (1)(2)(3) \endcode + */ +#define PP_TAIL(...) PP_TAIL_IMPL(__VA_ARGS__) + +//! Extracts the element with the specified index from the sequence. +/*! For example, \code PP_ELEMENT((0)(1)(2)(3), 1) == 1 \endcode + */ +#define PP_ELEMENT(seq, index) PP_ELEMENT_IMPL(seq, index) + +//! Applies the macro to every member of the sequence. +/*! For example, + * \code + * #define MyFunctor(x) +x+ + * PP_FOR_EACH(MyFunctor, (0)(1)(2)(3)) == +0+ +1+ +2+ +3+ + * \encode + */ +#define PP_FOR_EACH(what, seq) PP_FOR_EACH_IMPL(what, seq) + +//! Declares an anonymous variable. +#ifdef __COUNTER__ +#define PP_ANONYMOUS_VARIABLE(str) PP_CONCAT(str, __COUNTER__) +#else +#define PP_ANONYMOUS_VARIABLE(str) PP_CONCAT(str, __LINE__) +#endif + +//! Insert prefix based on presence of additional arguments. +#define PP_ONE_OR_NONE(a, ...) PP_THIRD(a, ## __VA_ARGS__, a) +#define PP_THIRD(a, b, ...) __VA_ARGS__ + +//! \cond Implementation +#define PREPROCESSOR_GEN_H_ +#include "preprocessor-gen.h" +#undef PREPROCESSOR_GEN_H_ +//! \endcond + +/*! \} */ + diff --git a/library/cpp/yt/misc/property.h b/library/cpp/yt/misc/property.h index bef8024ae1..1bf1f1dfb6 100644 --- a/library/cpp/yt/misc/property.h +++ b/library/cpp/yt/misc/property.h @@ -8,40 +8,40 @@ public: \ type& name(); \ const type& name() const; -//! Defines a trivial public read-write property that is passed by reference. -//! All arguments after name are used as default value (via braced-init-list). -#define DEFINE_BYREF_RW_PROPERTY(type, name, ...) \ -protected: \ - type name##_ { __VA_ARGS__ }; \ +//! Defines a trivial public read-write property that is passed by reference. +//! All arguments after name are used as default value (via braced-init-list). +#define DEFINE_BYREF_RW_PROPERTY(type, name, ...) \ +protected: \ + type name##_ { __VA_ARGS__ }; \ \ public: \ - Y_FORCE_INLINE type& name() \ + Y_FORCE_INLINE type& name() \ { \ return name##_; \ } \ \ - Y_FORCE_INLINE const type& name() const \ - { \ - return name##_; \ - } - -//! Defines a trivial public read-write property that is passed by reference -//! and is not inline-initialized. -#define DEFINE_BYREF_RW_PROPERTY_NO_INIT(type, name) \ -protected: \ - type name##_; \ - \ -public: \ - Y_FORCE_INLINE type& name() \ - { \ - return name##_; \ - } \ - \ - Y_FORCE_INLINE const type& name() const \ + Y_FORCE_INLINE const type& name() const \ { \ return name##_; \ } +//! Defines a trivial public read-write property that is passed by reference +//! and is not inline-initialized. +#define DEFINE_BYREF_RW_PROPERTY_NO_INIT(type, name) \ +protected: \ + type name##_; \ + \ +public: \ + Y_FORCE_INLINE type& name() \ + { \ + return name##_; \ + } \ + \ + Y_FORCE_INLINE const type& name() const \ + { \ + return name##_; \ + } + //! Forwards a trivial public read-write property that is passed by reference. #define DELEGATE_BYREF_RW_PROPERTY(declaringType, type, name, delegateTo) \ type& declaringType::name() \ @@ -59,32 +59,32 @@ public: \ //! Declares a trivial public read-only property that is passed by reference. #define DECLARE_BYREF_RO_PROPERTY(type, name) \ public: \ - const type& name() const; - -//! Defines a trivial public read-only property that is passed by reference. -//! All arguments after name are used as default value (via braced-init-list). -#define DEFINE_BYREF_RO_PROPERTY(type, name, ...) \ -protected: \ - type name##_ { __VA_ARGS__ }; \ - \ -public: \ - Y_FORCE_INLINE const type& name() const \ - { \ - return name##_; \ - } - -//! Defines a trivial public read-only property that is passed by reference -//! and is not inline-initialized. -#define DEFINE_BYREF_RO_PROPERTY_NO_INIT(type, name) \ -protected: \ - type name##_; \ - \ -public: \ - Y_FORCE_INLINE const type& name() const \ - { \ - return name##_; \ - } + const type& name() const; +//! Defines a trivial public read-only property that is passed by reference. +//! All arguments after name are used as default value (via braced-init-list). +#define DEFINE_BYREF_RO_PROPERTY(type, name, ...) \ +protected: \ + type name##_ { __VA_ARGS__ }; \ + \ +public: \ + Y_FORCE_INLINE const type& name() const \ + { \ + return name##_; \ + } + +//! Defines a trivial public read-only property that is passed by reference +//! and is not inline-initialized. +#define DEFINE_BYREF_RO_PROPERTY_NO_INIT(type, name) \ +protected: \ + type name##_; \ + \ +public: \ + Y_FORCE_INLINE const type& name() const \ + { \ + return name##_; \ + } + //! Forwards a trivial public read-only property that is passed by reference. #define DELEGATE_BYREF_RO_PROPERTY(declaringType, type, name, delegateTo) \ const type& declaringType::name() const \ @@ -98,21 +98,21 @@ public: \ #define DECLARE_BYVAL_RW_PROPERTY(type, name) \ public: \ type Get##name() const; \ - void Set##name(type value); + void Set##name(type value); -//! Defines a trivial public read-write property that is passed by value. -//! All arguments after name are used as default value (via braced-init-list). -#define DEFINE_BYVAL_RW_PROPERTY(type, name, ...) \ -protected: \ - type name##_ { __VA_ARGS__ }; \ +//! Defines a trivial public read-write property that is passed by value. +//! All arguments after name are used as default value (via braced-init-list). +#define DEFINE_BYVAL_RW_PROPERTY(type, name, ...) \ +protected: \ + type name##_ { __VA_ARGS__ }; \ \ public: \ - Y_FORCE_INLINE type Get##name() const \ + Y_FORCE_INLINE type Get##name() const \ { \ return name##_; \ } \ \ - Y_FORCE_INLINE void Set##name(type value) \ + Y_FORCE_INLINE void Set##name(type value) \ { \ name##_ = value; \ } \ @@ -139,24 +139,24 @@ public: \ name##_ = value; \ return std::move(*this); \ } \ - -//! Defines a trivial public read-write property that is passed by value -//! and is not inline-initialized. -#define DEFINE_BYVAL_RW_PROPERTY_NO_INIT(type, name, ...) \ -protected: \ - type name##_; \ - \ -public: \ - Y_FORCE_INLINE type Get##name() const \ - { \ - return name##_; \ - } \ - \ - Y_FORCE_INLINE void Set##name(type value) \ - { \ - name##_ = value; \ - } \ - + +//! Defines a trivial public read-write property that is passed by value +//! and is not inline-initialized. +#define DEFINE_BYVAL_RW_PROPERTY_NO_INIT(type, name, ...) \ +protected: \ + type name##_; \ + \ +public: \ + Y_FORCE_INLINE type Get##name() const \ + { \ + return name##_; \ + } \ + \ + Y_FORCE_INLINE void Set##name(type value) \ + { \ + name##_ = value; \ + } \ + //! Forwards a trivial public read-write property that is passed by value. #define DELEGATE_BYVAL_RW_PROPERTY(declaringType, type, name, delegateTo) \ type declaringType::Get##name() const \ @@ -164,7 +164,7 @@ public: \ return (delegateTo).Get##name(); \ } \ \ - void declaringType::Set##name(type value) \ + void declaringType::Set##name(type value) \ { \ (delegateTo).Set##name(value); \ } @@ -176,31 +176,31 @@ public: \ public: \ type Get##name() const; -//! Defines a trivial public read-only property that is passed by value. -//! All arguments after name are used as default value (via braced-init-list). -#define DEFINE_BYVAL_RO_PROPERTY(type, name, ...) \ -protected: \ - type name##_ { __VA_ARGS__ }; \ - \ -public: \ - Y_FORCE_INLINE type Get##name() const \ - { \ - return name##_; \ - } - - -//! Defines a trivial public read-only property that is passed by value -//! and is not inline-initialized. -#define DEFINE_BYVAL_RO_PROPERTY_NO_INIT(type, name) \ -protected: \ - type name##_; \ - \ -public: \ - Y_FORCE_INLINE type Get##name() const \ - { \ - return name##_; \ - } - +//! Defines a trivial public read-only property that is passed by value. +//! All arguments after name are used as default value (via braced-init-list). +#define DEFINE_BYVAL_RO_PROPERTY(type, name, ...) \ +protected: \ + type name##_ { __VA_ARGS__ }; \ + \ +public: \ + Y_FORCE_INLINE type Get##name() const \ + { \ + return name##_; \ + } + + +//! Defines a trivial public read-only property that is passed by value +//! and is not inline-initialized. +#define DEFINE_BYVAL_RO_PROPERTY_NO_INIT(type, name) \ +protected: \ + type name##_; \ + \ +public: \ + Y_FORCE_INLINE type Get##name() const \ + { \ + return name##_; \ + } + //! Forwards a trivial public read-only property that is passed by value. #define DELEGATE_BYVAL_RO_PROPERTY(declaringType, type, name, delegateTo) \ type declaringType::Get##name() \ diff --git a/library/cpp/yt/misc/source_location.cpp b/library/cpp/yt/misc/source_location.cpp index 8d22d43636..c632378050 100644 --- a/library/cpp/yt/misc/source_location.cpp +++ b/library/cpp/yt/misc/source_location.cpp @@ -1,54 +1,54 @@ -#include "source_location.h" - -#include <string.h> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -const char* TSourceLocation::GetFileName() const -{ - return FileName_; -} - -int TSourceLocation::GetLine() const -{ - return Line_; -} - -bool TSourceLocation::IsValid() const -{ - return FileName_ != nullptr; -} - -bool TSourceLocation::operator<(const TSourceLocation& other) const -{ - const char* fileName = FileName_ ? FileName_ : ""; - const char* otherFileName = other.FileName_ ? other.FileName_ : ""; - int fileNameResult = strcmp(fileName, otherFileName); - if (fileNameResult != 0) { +#include "source_location.h" + +#include <string.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +const char* TSourceLocation::GetFileName() const +{ + return FileName_; +} + +int TSourceLocation::GetLine() const +{ + return Line_; +} + +bool TSourceLocation::IsValid() const +{ + return FileName_ != nullptr; +} + +bool TSourceLocation::operator<(const TSourceLocation& other) const +{ + const char* fileName = FileName_ ? FileName_ : ""; + const char* otherFileName = other.FileName_ ? other.FileName_ : ""; + int fileNameResult = strcmp(fileName, otherFileName); + if (fileNameResult != 0) { return fileNameResult < 0; - } - - if (Line_ < other.Line_) { - return true; - } - if (Line_ > other.Line_) { - return false; - } - - return false; -} - -bool TSourceLocation::operator==(const TSourceLocation& other) const -{ - const char* fileName = FileName_ ? FileName_ : ""; - const char* otherFileName = other.FileName_ ? other.FileName_ : ""; - return - strcmp(fileName, otherFileName) == 0 && - Line_ == other.Line_; -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT + } + + if (Line_ < other.Line_) { + return true; + } + if (Line_ > other.Line_) { + return false; + } + + return false; +} + +bool TSourceLocation::operator==(const TSourceLocation& other) const +{ + const char* fileName = FileName_ ? FileName_ : ""; + const char* otherFileName = other.FileName_ ? other.FileName_ : ""; + return + strcmp(fileName, otherFileName) == 0 && + Line_ == other.Line_; +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/library/cpp/yt/misc/source_location.h b/library/cpp/yt/misc/source_location.h index 84213eea70..b59896fcdd 100644 --- a/library/cpp/yt/misc/source_location.h +++ b/library/cpp/yt/misc/source_location.h @@ -1,38 +1,38 @@ -#pragma once - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -class TSourceLocation -{ -public: - TSourceLocation() - : FileName_(nullptr) - , Line_(-1) - { } - - TSourceLocation(const char* fileName, int line) - : FileName_(fileName) - , Line_(line) - { } - - const char* GetFileName() const; - int GetLine() const; - bool IsValid() const; - - bool operator<(const TSourceLocation& other) const; - bool operator==(const TSourceLocation& other) const; - -private: - const char* FileName_; - int Line_; - -}; - -//! Defines a macro to record the current source location. -#define FROM_HERE ::NYT::TSourceLocation(__FILE__, __LINE__) - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +#pragma once + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +class TSourceLocation +{ +public: + TSourceLocation() + : FileName_(nullptr) + , Line_(-1) + { } + + TSourceLocation(const char* fileName, int line) + : FileName_(fileName) + , Line_(line) + { } + + const char* GetFileName() const; + int GetLine() const; + bool IsValid() const; + + bool operator<(const TSourceLocation& other) const; + bool operator==(const TSourceLocation& other) const; + +private: + const char* FileName_; + int Line_; + +}; + +//! Defines a macro to record the current source location. +#define FROM_HERE ::NYT::TSourceLocation(__FILE__, __LINE__) + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/library/cpp/yt/misc/unittests/enum_ut.cpp b/library/cpp/yt/misc/unittests/enum_ut.cpp index 6af11b04dc..0ee906d2ae 100644 --- a/library/cpp/yt/misc/unittests/enum_ut.cpp +++ b/library/cpp/yt/misc/unittests/enum_ut.cpp @@ -1,250 +1,250 @@ #include <library/cpp/testing/gtest/gtest.h> - + #include <library/cpp/yt/misc/enum.h> - -namespace NYT { -namespace { - -//////////////////////////////////////////////////////////////////////////////// - -DEFINE_ENUM(ESimple, - (X) - (Y) - (Z) -); - -DEFINE_ENUM(EColor, - ((Red) (10)) - ((Green)(20)) - ((Blue) (30)) - (Black) - (White) -); - -DEFINE_BIT_ENUM(EFlag, - ((_1)(0x0001)) - ((_2)(0x0002)) - ((_3)(0x0004)) - ((_4)(0x0008)) -); - -DEFINE_AMBIGUOUS_ENUM_WITH_UNDERLYING_TYPE(EMultipleNames, int, - (A1) - ((A2)(0)) - (B) - (C) - ((D1)(100)) - ((D2)(100)) -); - -//////////////////////////////////////////////////////////////////////////////// - -template <class T, size_t N> -std::vector<T> ToVector(std::array<T, N> array) -{ - return std::vector<T>(array.begin(), array.end()); -} - -TEST(TEnumTest, Domain) -{ - EXPECT_EQ(3, TEnumTraits<ESimple>::DomainSize); - std::vector<ESimple> v { - ESimple::X, - ESimple::Y, - ESimple::Z - }; - EXPECT_EQ(v, ToVector(TEnumTraits<ESimple>::GetDomainValues())); - EXPECT_EQ(ESimple::X, TEnumTraits<ESimple>::GetMinValue()); - EXPECT_EQ(ESimple::Z, TEnumTraits<ESimple>::GetMaxValue()); -} - -TEST(TEnumTest, Basic) -{ - EXPECT_EQ(0, static_cast<int>(ESimple::X)); - EXPECT_EQ(1, static_cast<int>(ESimple::Y)); - EXPECT_EQ(2, static_cast<int>(ESimple::Z)); - - EXPECT_EQ(0, static_cast<int>(EColor( ))); - EXPECT_EQ(5, static_cast<int>(EColor(5))); - - EXPECT_EQ(10, static_cast<int>(EColor::Red )); - EXPECT_EQ(20, static_cast<int>(EColor::Green)); - EXPECT_EQ(30, static_cast<int>(EColor::Blue )); - EXPECT_EQ(31, static_cast<int>(EColor::Black)); - EXPECT_EQ(32, static_cast<int>(EColor::White)); -} - -TEST(TEnumTest, ToString) -{ - EXPECT_EQ("EColor(0)", ToString(EColor( ))); - EXPECT_EQ("EColor(5)", ToString(EColor(5))); - - EXPECT_EQ("Red", ToString(EColor(EColor::Red ))); - EXPECT_EQ("Green", ToString(EColor::Green)); - EXPECT_EQ("Blue", ToString(EColor(EColor::Blue ))); - EXPECT_EQ("Black", ToString(EColor::Black)); - EXPECT_EQ("White", ToString(EColor::White)); -} - -TEST(TEnumTest, FromString) -{ - EXPECT_EQ(EColor::Red , TEnumTraits<EColor>::FromString("Red" )); - EXPECT_EQ(EColor::Green, TEnumTraits<EColor>::FromString("Green")); - EXPECT_EQ(EColor::Blue , TEnumTraits<EColor>::FromString("Blue" )); - EXPECT_EQ(EColor::Black, TEnumTraits<EColor>::FromString("Black")); - EXPECT_EQ(EColor::White, TEnumTraits<EColor>::FromString("White")); - - EXPECT_THROW(TEnumTraits<EColor>::FromString("Pink"), std::exception); - - EColor color; - bool returnValue; - - returnValue = TEnumTraits<EColor>::FindValueByLiteral("Red", &color); - EXPECT_EQ(EColor::Red, color); - EXPECT_TRUE(returnValue); - - returnValue = TEnumTraits<EColor>::FindValueByLiteral("Pink", &color); - EXPECT_EQ(EColor::Red, color); - EXPECT_FALSE(returnValue); -} - -TEST(TEnumTest, Ordering) -{ - ESimple a(ESimple::X); - ESimple b(ESimple::Y); - ESimple c(ESimple::Y); - ESimple d(ESimple::Z); - - EXPECT_FALSE(a < a); EXPECT_FALSE(a > a); - EXPECT_TRUE (a < b); EXPECT_TRUE (b > a); - EXPECT_TRUE (a < c); EXPECT_TRUE (c > a); - EXPECT_TRUE (a < d); EXPECT_TRUE (d > a); - - EXPECT_FALSE(b < a); EXPECT_FALSE(a > b); - EXPECT_FALSE(b < b); EXPECT_FALSE(b > b); - EXPECT_FALSE(b < c); EXPECT_FALSE(c > b); - EXPECT_TRUE (b < d); EXPECT_TRUE (d > b); - - EXPECT_FALSE(c < a); EXPECT_FALSE(a > c); - EXPECT_FALSE(c < b); EXPECT_FALSE(b > c); - EXPECT_FALSE(c < c); EXPECT_FALSE(c > c); - EXPECT_TRUE (c < d); EXPECT_TRUE (d > c); - - EXPECT_FALSE(d < a); EXPECT_FALSE(a > d); - EXPECT_FALSE(d < b); EXPECT_FALSE(b > d); - EXPECT_FALSE(d < c); EXPECT_FALSE(c > d); - EXPECT_FALSE(d < d); EXPECT_FALSE(d > d); - - EXPECT_TRUE (a <= b); - EXPECT_TRUE (b <= c); - EXPECT_TRUE (c <= d); - - EXPECT_TRUE (a == a); - EXPECT_FALSE(a == b); - EXPECT_TRUE (b == c); - EXPECT_FALSE(c == d); - EXPECT_FALSE(d == a); - - EXPECT_FALSE(a != a); - EXPECT_TRUE (a != b); - EXPECT_FALSE(b != c); - EXPECT_TRUE (c != d); - EXPECT_TRUE (d != a); -} - -TEST(TEnumTest, OrderingWithDomainValues) -{ - EColor color(EColor::Black); - - EXPECT_LT(EColor::Red, color); - EXPECT_LT(color, EColor::White); - - EXPECT_GT(color, EColor::Red); - EXPECT_GT(EColor::White, color); - - EXPECT_LE(EColor::Red, color); - EXPECT_LE(color, EColor::White); - - EXPECT_GE(EColor::White, color); - EXPECT_GE(color, EColor::Red); - - EXPECT_EQ(color, EColor::Black); - EXPECT_EQ(EColor::Black, color); - - EXPECT_NE(color, EColor::Blue); - EXPECT_NE(EColor::Blue, color); -} - -TEST(TEnumTest, DomainSize) -{ - EXPECT_EQ(3, TEnumTraits<ESimple>::DomainSize); - EXPECT_EQ(5, TEnumTraits<EColor>::DomainSize); -} - -TEST(TEnumTest, DomainValues) -{ - std::vector<ESimple> simpleValues; - simpleValues.push_back(ESimple::X); - simpleValues.push_back(ESimple::Y); - simpleValues.push_back(ESimple::Z); - EXPECT_EQ(simpleValues, ToVector(TEnumTraits<ESimple>::GetDomainValues())); - - std::vector<EColor> colorValues; - colorValues.push_back(EColor::Red); - colorValues.push_back(EColor::Green); - colorValues.push_back(EColor::Blue); - colorValues.push_back(EColor::Black); - colorValues.push_back(EColor::White); - EXPECT_EQ(colorValues, ToVector(TEnumTraits<EColor>::GetDomainValues())); -} - -TEST(TEnumTest, Decompose1) -{ - auto f = EFlag(0); - std::vector<EFlag> ff { }; - EXPECT_EQ(TEnumTraits<EFlag>::Decompose(f), ff); -} - -TEST(TEnumTest, Decompose2) -{ - auto f = EFlag::_1; - std::vector<EFlag> ff {EFlag::_1}; - EXPECT_EQ(TEnumTraits<EFlag>::Decompose(f), ff); -} - -TEST(TEnumTest, Decompose3) -{ - auto f = EFlag(EFlag::_1|EFlag::_2); - std::vector<EFlag> ff{EFlag::_1, EFlag::_2}; - EXPECT_EQ(TEnumTraits<EFlag>::Decompose(f), ff); -} - -TEST(TEnumTest, Decompose4) -{ - auto f = EFlag(EFlag::_2|EFlag::_4); - std::vector<EFlag> ff{EFlag::_2, EFlag::_4}; - EXPECT_EQ(TEnumTraits<EFlag>::Decompose(f), ff); -} - -TEST(TEnumTest, MultipleNames) -{ - EXPECT_EQ(EMultipleNames::A1, TEnumTraits<EMultipleNames>::FromString("A1")); - EXPECT_EQ(EMultipleNames::A1, TEnumTraits<EMultipleNames>::FromString("A2")); - EXPECT_EQ(EMultipleNames::B, TEnumTraits<EMultipleNames>::FromString("B")); - EXPECT_EQ(EMultipleNames::C, TEnumTraits<EMultipleNames>::FromString("C")); - EXPECT_EQ(EMultipleNames::D1, TEnumTraits<EMultipleNames>::FromString("D1")); - EXPECT_EQ(EMultipleNames::D1, TEnumTraits<EMultipleNames>::FromString("D2")); - - EXPECT_EQ("A1", ToString(EMultipleNames::A1)); - EXPECT_EQ("A1", ToString(EMultipleNames::A2)); - EXPECT_EQ("B", ToString(EMultipleNames::B)); - EXPECT_EQ("C", ToString(EMultipleNames::C)); - EXPECT_EQ("D1", ToString(EMultipleNames::D1)); - EXPECT_EQ("D1", ToString(EMultipleNames::D2)); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace -} // namespace NYT - + +namespace NYT { +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +DEFINE_ENUM(ESimple, + (X) + (Y) + (Z) +); + +DEFINE_ENUM(EColor, + ((Red) (10)) + ((Green)(20)) + ((Blue) (30)) + (Black) + (White) +); + +DEFINE_BIT_ENUM(EFlag, + ((_1)(0x0001)) + ((_2)(0x0002)) + ((_3)(0x0004)) + ((_4)(0x0008)) +); + +DEFINE_AMBIGUOUS_ENUM_WITH_UNDERLYING_TYPE(EMultipleNames, int, + (A1) + ((A2)(0)) + (B) + (C) + ((D1)(100)) + ((D2)(100)) +); + +//////////////////////////////////////////////////////////////////////////////// + +template <class T, size_t N> +std::vector<T> ToVector(std::array<T, N> array) +{ + return std::vector<T>(array.begin(), array.end()); +} + +TEST(TEnumTest, Domain) +{ + EXPECT_EQ(3, TEnumTraits<ESimple>::DomainSize); + std::vector<ESimple> v { + ESimple::X, + ESimple::Y, + ESimple::Z + }; + EXPECT_EQ(v, ToVector(TEnumTraits<ESimple>::GetDomainValues())); + EXPECT_EQ(ESimple::X, TEnumTraits<ESimple>::GetMinValue()); + EXPECT_EQ(ESimple::Z, TEnumTraits<ESimple>::GetMaxValue()); +} + +TEST(TEnumTest, Basic) +{ + EXPECT_EQ(0, static_cast<int>(ESimple::X)); + EXPECT_EQ(1, static_cast<int>(ESimple::Y)); + EXPECT_EQ(2, static_cast<int>(ESimple::Z)); + + EXPECT_EQ(0, static_cast<int>(EColor( ))); + EXPECT_EQ(5, static_cast<int>(EColor(5))); + + EXPECT_EQ(10, static_cast<int>(EColor::Red )); + EXPECT_EQ(20, static_cast<int>(EColor::Green)); + EXPECT_EQ(30, static_cast<int>(EColor::Blue )); + EXPECT_EQ(31, static_cast<int>(EColor::Black)); + EXPECT_EQ(32, static_cast<int>(EColor::White)); +} + +TEST(TEnumTest, ToString) +{ + EXPECT_EQ("EColor(0)", ToString(EColor( ))); + EXPECT_EQ("EColor(5)", ToString(EColor(5))); + + EXPECT_EQ("Red", ToString(EColor(EColor::Red ))); + EXPECT_EQ("Green", ToString(EColor::Green)); + EXPECT_EQ("Blue", ToString(EColor(EColor::Blue ))); + EXPECT_EQ("Black", ToString(EColor::Black)); + EXPECT_EQ("White", ToString(EColor::White)); +} + +TEST(TEnumTest, FromString) +{ + EXPECT_EQ(EColor::Red , TEnumTraits<EColor>::FromString("Red" )); + EXPECT_EQ(EColor::Green, TEnumTraits<EColor>::FromString("Green")); + EXPECT_EQ(EColor::Blue , TEnumTraits<EColor>::FromString("Blue" )); + EXPECT_EQ(EColor::Black, TEnumTraits<EColor>::FromString("Black")); + EXPECT_EQ(EColor::White, TEnumTraits<EColor>::FromString("White")); + + EXPECT_THROW(TEnumTraits<EColor>::FromString("Pink"), std::exception); + + EColor color; + bool returnValue; + + returnValue = TEnumTraits<EColor>::FindValueByLiteral("Red", &color); + EXPECT_EQ(EColor::Red, color); + EXPECT_TRUE(returnValue); + + returnValue = TEnumTraits<EColor>::FindValueByLiteral("Pink", &color); + EXPECT_EQ(EColor::Red, color); + EXPECT_FALSE(returnValue); +} + +TEST(TEnumTest, Ordering) +{ + ESimple a(ESimple::X); + ESimple b(ESimple::Y); + ESimple c(ESimple::Y); + ESimple d(ESimple::Z); + + EXPECT_FALSE(a < a); EXPECT_FALSE(a > a); + EXPECT_TRUE (a < b); EXPECT_TRUE (b > a); + EXPECT_TRUE (a < c); EXPECT_TRUE (c > a); + EXPECT_TRUE (a < d); EXPECT_TRUE (d > a); + + EXPECT_FALSE(b < a); EXPECT_FALSE(a > b); + EXPECT_FALSE(b < b); EXPECT_FALSE(b > b); + EXPECT_FALSE(b < c); EXPECT_FALSE(c > b); + EXPECT_TRUE (b < d); EXPECT_TRUE (d > b); + + EXPECT_FALSE(c < a); EXPECT_FALSE(a > c); + EXPECT_FALSE(c < b); EXPECT_FALSE(b > c); + EXPECT_FALSE(c < c); EXPECT_FALSE(c > c); + EXPECT_TRUE (c < d); EXPECT_TRUE (d > c); + + EXPECT_FALSE(d < a); EXPECT_FALSE(a > d); + EXPECT_FALSE(d < b); EXPECT_FALSE(b > d); + EXPECT_FALSE(d < c); EXPECT_FALSE(c > d); + EXPECT_FALSE(d < d); EXPECT_FALSE(d > d); + + EXPECT_TRUE (a <= b); + EXPECT_TRUE (b <= c); + EXPECT_TRUE (c <= d); + + EXPECT_TRUE (a == a); + EXPECT_FALSE(a == b); + EXPECT_TRUE (b == c); + EXPECT_FALSE(c == d); + EXPECT_FALSE(d == a); + + EXPECT_FALSE(a != a); + EXPECT_TRUE (a != b); + EXPECT_FALSE(b != c); + EXPECT_TRUE (c != d); + EXPECT_TRUE (d != a); +} + +TEST(TEnumTest, OrderingWithDomainValues) +{ + EColor color(EColor::Black); + + EXPECT_LT(EColor::Red, color); + EXPECT_LT(color, EColor::White); + + EXPECT_GT(color, EColor::Red); + EXPECT_GT(EColor::White, color); + + EXPECT_LE(EColor::Red, color); + EXPECT_LE(color, EColor::White); + + EXPECT_GE(EColor::White, color); + EXPECT_GE(color, EColor::Red); + + EXPECT_EQ(color, EColor::Black); + EXPECT_EQ(EColor::Black, color); + + EXPECT_NE(color, EColor::Blue); + EXPECT_NE(EColor::Blue, color); +} + +TEST(TEnumTest, DomainSize) +{ + EXPECT_EQ(3, TEnumTraits<ESimple>::DomainSize); + EXPECT_EQ(5, TEnumTraits<EColor>::DomainSize); +} + +TEST(TEnumTest, DomainValues) +{ + std::vector<ESimple> simpleValues; + simpleValues.push_back(ESimple::X); + simpleValues.push_back(ESimple::Y); + simpleValues.push_back(ESimple::Z); + EXPECT_EQ(simpleValues, ToVector(TEnumTraits<ESimple>::GetDomainValues())); + + std::vector<EColor> colorValues; + colorValues.push_back(EColor::Red); + colorValues.push_back(EColor::Green); + colorValues.push_back(EColor::Blue); + colorValues.push_back(EColor::Black); + colorValues.push_back(EColor::White); + EXPECT_EQ(colorValues, ToVector(TEnumTraits<EColor>::GetDomainValues())); +} + +TEST(TEnumTest, Decompose1) +{ + auto f = EFlag(0); + std::vector<EFlag> ff { }; + EXPECT_EQ(TEnumTraits<EFlag>::Decompose(f), ff); +} + +TEST(TEnumTest, Decompose2) +{ + auto f = EFlag::_1; + std::vector<EFlag> ff {EFlag::_1}; + EXPECT_EQ(TEnumTraits<EFlag>::Decompose(f), ff); +} + +TEST(TEnumTest, Decompose3) +{ + auto f = EFlag(EFlag::_1|EFlag::_2); + std::vector<EFlag> ff{EFlag::_1, EFlag::_2}; + EXPECT_EQ(TEnumTraits<EFlag>::Decompose(f), ff); +} + +TEST(TEnumTest, Decompose4) +{ + auto f = EFlag(EFlag::_2|EFlag::_4); + std::vector<EFlag> ff{EFlag::_2, EFlag::_4}; + EXPECT_EQ(TEnumTraits<EFlag>::Decompose(f), ff); +} + +TEST(TEnumTest, MultipleNames) +{ + EXPECT_EQ(EMultipleNames::A1, TEnumTraits<EMultipleNames>::FromString("A1")); + EXPECT_EQ(EMultipleNames::A1, TEnumTraits<EMultipleNames>::FromString("A2")); + EXPECT_EQ(EMultipleNames::B, TEnumTraits<EMultipleNames>::FromString("B")); + EXPECT_EQ(EMultipleNames::C, TEnumTraits<EMultipleNames>::FromString("C")); + EXPECT_EQ(EMultipleNames::D1, TEnumTraits<EMultipleNames>::FromString("D1")); + EXPECT_EQ(EMultipleNames::D1, TEnumTraits<EMultipleNames>::FromString("D2")); + + EXPECT_EQ("A1", ToString(EMultipleNames::A1)); + EXPECT_EQ("A1", ToString(EMultipleNames::A2)); + EXPECT_EQ("B", ToString(EMultipleNames::B)); + EXPECT_EQ("C", ToString(EMultipleNames::C)); + EXPECT_EQ("D1", ToString(EMultipleNames::D1)); + EXPECT_EQ("D1", ToString(EMultipleNames::D2)); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace +} // namespace NYT + diff --git a/library/cpp/yt/misc/unittests/guid_ut.cpp b/library/cpp/yt/misc/unittests/guid_ut.cpp index ce9ee52109..bbbd6037aa 100644 --- a/library/cpp/yt/misc/unittests/guid_ut.cpp +++ b/library/cpp/yt/misc/unittests/guid_ut.cpp @@ -1,20 +1,20 @@ #include <library/cpp/testing/gtest/gtest.h> - + #include <library/cpp/yt/misc/guid.h> - -namespace NYT { -namespace { - -//////////////////////////////////////////////////////////////////////////////// - -TEST(TGuidTest, RandomGuids) -{ - auto guid = TGuid::Create(); - auto otherGuid = TGuid::Create(); - EXPECT_FALSE(guid == otherGuid); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace -} // namespace NYT + +namespace NYT { +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +TEST(TGuidTest, RandomGuids) +{ + auto guid = TGuid::Create(); + auto otherGuid = TGuid::Create(); + EXPECT_FALSE(guid == otherGuid); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace +} // namespace NYT diff --git a/library/cpp/yt/misc/unittests/preprocessor_ut.cpp b/library/cpp/yt/misc/unittests/preprocessor_ut.cpp index 397e2a6a61..b8ec44c00b 100644 --- a/library/cpp/yt/misc/unittests/preprocessor_ut.cpp +++ b/library/cpp/yt/misc/unittests/preprocessor_ut.cpp @@ -1,102 +1,102 @@ -#include <library/cpp/testing/gtest/gtest.h> - -#include <library/cpp/yt/misc/preprocessor.h> - -namespace NYT { -namespace { - -//////////////////////////////////////////////////////////////////////////////// - -TEST(TPreprocessorTest, Concatenation) -{ - EXPECT_EQ(12, PP_CONCAT(1, 2)); - EXPECT_STREQ("FooBar", PP_STRINGIZE(PP_CONCAT(Foo, Bar))); -} - -TEST(TPreprocessorTest, Stringize) -{ - EXPECT_STREQ(PP_STRINGIZE(123456), "123456"); - EXPECT_STREQ(PP_STRINGIZE(FooBar), "FooBar"); - EXPECT_STREQ(PP_STRINGIZE(T::XYZ), "T::XYZ"); -} - -TEST(TPreprocessorTest, Count) -{ - EXPECT_EQ(0, PP_COUNT()); - EXPECT_EQ(1, PP_COUNT((0))); - EXPECT_EQ(2, PP_COUNT((0)(0))); - EXPECT_EQ(3, PP_COUNT((0)(0)(0))); - EXPECT_EQ(4, PP_COUNT((0)(0)(0)(0))); - EXPECT_EQ(5, PP_COUNT((0)(0)(0)(0)(0))); -} - -TEST(TPreprocessorTest, Kill) -{ - EXPECT_STREQ("PP_NIL (0)", PP_STRINGIZE(PP_NIL PP_KILL((0), 0))); - EXPECT_STREQ("PP_NIL", PP_STRINGIZE(PP_NIL PP_KILL((0), 1))); - EXPECT_STREQ("PP_NIL (0)(1)(2)", PP_STRINGIZE(PP_NIL PP_KILL((0)(1)(2), 0))); - EXPECT_STREQ("PP_NIL (1)(2)", PP_STRINGIZE(PP_NIL PP_KILL((0)(1)(2), 1))); - EXPECT_STREQ("PP_NIL (2)", PP_STRINGIZE(PP_NIL PP_KILL((0)(1)(2), 2))); - EXPECT_STREQ("PP_NIL", PP_STRINGIZE(PP_NIL PP_KILL((0)(1)(2), 3))); -} - -TEST(TPreprocessorTest, Head) -{ - EXPECT_STREQ("0", PP_STRINGIZE(PP_HEAD((0)))); - EXPECT_STREQ("0", PP_STRINGIZE(PP_HEAD((0)(1)))); - EXPECT_STREQ("0", PP_STRINGIZE(PP_HEAD((0)(1)(2)))); -} - -TEST(TPreprocessorTest, Tail) -{ - EXPECT_STREQ("PP_NIL", PP_STRINGIZE(PP_NIL PP_TAIL((0)))); - EXPECT_STREQ("PP_NIL (1)", PP_STRINGIZE(PP_NIL PP_TAIL((0)(1)))); - EXPECT_STREQ("PP_NIL (1)(2)", PP_STRINGIZE(PP_NIL PP_TAIL((0)(1)(2)))); -} - -TEST(TPreprocessorTest, ForEach) -{ - EXPECT_STREQ( - "\"Foo\" \"Bar\" \"Spam\" \"Ham\"", - PP_STRINGIZE(PP_FOR_EACH(PP_STRINGIZE, (Foo)(Bar)(Spam)(Ham))) - ); -#define my_functor(x) +x+ - EXPECT_STREQ( - "+1+ +2+ +3+", - PP_STRINGIZE(PP_FOR_EACH(my_functor, (1)(2)(3))) - ); -#undef my_functor -} - -TEST(TPreprocessorTest, MakeSingleton) -{ - EXPECT_EQ(1, PP_ELEMENT((1), 0)); - EXPECT_EQ(1, PP_ELEMENT((1)(2), 0)); - EXPECT_EQ(2, PP_ELEMENT((1)(2), 1)); - EXPECT_EQ(1, PP_ELEMENT((1)(2)(3), 0)); - EXPECT_EQ(2, PP_ELEMENT((1)(2)(3), 1)); - EXPECT_EQ(3, PP_ELEMENT((1)(2)(3), 2)); - EXPECT_EQ(1, PP_ELEMENT((1)(2)(3)(4), 0)); - EXPECT_EQ(2, PP_ELEMENT((1)(2)(3)(4), 1)); - EXPECT_EQ(3, PP_ELEMENT((1)(2)(3)(4), 2)); - EXPECT_EQ(4, PP_ELEMENT((1)(2)(3)(4), 3)); -} - -TEST(TPreprocessorTest, Conditional) -{ - EXPECT_EQ(1, PP_IF(PP_TRUE, 1, 2)); - EXPECT_EQ(2, PP_IF(PP_FALSE, 1, 2)); -} - -TEST(TPreprocessorTest, IsSequence) -{ - EXPECT_STREQ("PP_FALSE", PP_STRINGIZE(PP_IS_SEQUENCE( 0 ))); - EXPECT_STREQ("PP_TRUE", PP_STRINGIZE(PP_IS_SEQUENCE((0) ))); - EXPECT_STREQ("PP_TRUE", PP_STRINGIZE(PP_IS_SEQUENCE((0)(0)))); - EXPECT_STREQ("PP_FALSE", PP_STRINGIZE(PP_IS_SEQUENCE(PP_NIL))); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace -} // namespace NYT +#include <library/cpp/testing/gtest/gtest.h> + +#include <library/cpp/yt/misc/preprocessor.h> + +namespace NYT { +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +TEST(TPreprocessorTest, Concatenation) +{ + EXPECT_EQ(12, PP_CONCAT(1, 2)); + EXPECT_STREQ("FooBar", PP_STRINGIZE(PP_CONCAT(Foo, Bar))); +} + +TEST(TPreprocessorTest, Stringize) +{ + EXPECT_STREQ(PP_STRINGIZE(123456), "123456"); + EXPECT_STREQ(PP_STRINGIZE(FooBar), "FooBar"); + EXPECT_STREQ(PP_STRINGIZE(T::XYZ), "T::XYZ"); +} + +TEST(TPreprocessorTest, Count) +{ + EXPECT_EQ(0, PP_COUNT()); + EXPECT_EQ(1, PP_COUNT((0))); + EXPECT_EQ(2, PP_COUNT((0)(0))); + EXPECT_EQ(3, PP_COUNT((0)(0)(0))); + EXPECT_EQ(4, PP_COUNT((0)(0)(0)(0))); + EXPECT_EQ(5, PP_COUNT((0)(0)(0)(0)(0))); +} + +TEST(TPreprocessorTest, Kill) +{ + EXPECT_STREQ("PP_NIL (0)", PP_STRINGIZE(PP_NIL PP_KILL((0), 0))); + EXPECT_STREQ("PP_NIL", PP_STRINGIZE(PP_NIL PP_KILL((0), 1))); + EXPECT_STREQ("PP_NIL (0)(1)(2)", PP_STRINGIZE(PP_NIL PP_KILL((0)(1)(2), 0))); + EXPECT_STREQ("PP_NIL (1)(2)", PP_STRINGIZE(PP_NIL PP_KILL((0)(1)(2), 1))); + EXPECT_STREQ("PP_NIL (2)", PP_STRINGIZE(PP_NIL PP_KILL((0)(1)(2), 2))); + EXPECT_STREQ("PP_NIL", PP_STRINGIZE(PP_NIL PP_KILL((0)(1)(2), 3))); +} + +TEST(TPreprocessorTest, Head) +{ + EXPECT_STREQ("0", PP_STRINGIZE(PP_HEAD((0)))); + EXPECT_STREQ("0", PP_STRINGIZE(PP_HEAD((0)(1)))); + EXPECT_STREQ("0", PP_STRINGIZE(PP_HEAD((0)(1)(2)))); +} + +TEST(TPreprocessorTest, Tail) +{ + EXPECT_STREQ("PP_NIL", PP_STRINGIZE(PP_NIL PP_TAIL((0)))); + EXPECT_STREQ("PP_NIL (1)", PP_STRINGIZE(PP_NIL PP_TAIL((0)(1)))); + EXPECT_STREQ("PP_NIL (1)(2)", PP_STRINGIZE(PP_NIL PP_TAIL((0)(1)(2)))); +} + +TEST(TPreprocessorTest, ForEach) +{ + EXPECT_STREQ( + "\"Foo\" \"Bar\" \"Spam\" \"Ham\"", + PP_STRINGIZE(PP_FOR_EACH(PP_STRINGIZE, (Foo)(Bar)(Spam)(Ham))) + ); +#define my_functor(x) +x+ + EXPECT_STREQ( + "+1+ +2+ +3+", + PP_STRINGIZE(PP_FOR_EACH(my_functor, (1)(2)(3))) + ); +#undef my_functor +} + +TEST(TPreprocessorTest, MakeSingleton) +{ + EXPECT_EQ(1, PP_ELEMENT((1), 0)); + EXPECT_EQ(1, PP_ELEMENT((1)(2), 0)); + EXPECT_EQ(2, PP_ELEMENT((1)(2), 1)); + EXPECT_EQ(1, PP_ELEMENT((1)(2)(3), 0)); + EXPECT_EQ(2, PP_ELEMENT((1)(2)(3), 1)); + EXPECT_EQ(3, PP_ELEMENT((1)(2)(3), 2)); + EXPECT_EQ(1, PP_ELEMENT((1)(2)(3)(4), 0)); + EXPECT_EQ(2, PP_ELEMENT((1)(2)(3)(4), 1)); + EXPECT_EQ(3, PP_ELEMENT((1)(2)(3)(4), 2)); + EXPECT_EQ(4, PP_ELEMENT((1)(2)(3)(4), 3)); +} + +TEST(TPreprocessorTest, Conditional) +{ + EXPECT_EQ(1, PP_IF(PP_TRUE, 1, 2)); + EXPECT_EQ(2, PP_IF(PP_FALSE, 1, 2)); +} + +TEST(TPreprocessorTest, IsSequence) +{ + EXPECT_STREQ("PP_FALSE", PP_STRINGIZE(PP_IS_SEQUENCE( 0 ))); + EXPECT_STREQ("PP_TRUE", PP_STRINGIZE(PP_IS_SEQUENCE((0) ))); + EXPECT_STREQ("PP_TRUE", PP_STRINGIZE(PP_IS_SEQUENCE((0)(0)))); + EXPECT_STREQ("PP_FALSE", PP_STRINGIZE(PP_IS_SEQUENCE(PP_NIL))); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace +} // namespace NYT diff --git a/library/cpp/yt/misc/unittests/ya.make b/library/cpp/yt/misc/unittests/ya.make index 690082ca59..539c7c1a4e 100644 --- a/library/cpp/yt/misc/unittests/ya.make +++ b/library/cpp/yt/misc/unittests/ya.make @@ -1,15 +1,15 @@ -GTEST(unittester-library-misc) - -OWNER(g:yt) - -SRCS( +GTEST(unittester-library-misc) + +OWNER(g:yt) + +SRCS( enum_ut.cpp guid_ut.cpp - preprocessor_ut.cpp -) - -PEERDIR( - library/cpp/yt/misc -) - -END() + preprocessor_ut.cpp +) + +PEERDIR( + library/cpp/yt/misc +) + +END() diff --git a/library/cpp/yt/misc/variant-inl.h b/library/cpp/yt/misc/variant-inl.h index fb7d98d4be..73d302eece 100644 --- a/library/cpp/yt/misc/variant-inl.h +++ b/library/cpp/yt/misc/variant-inl.h @@ -1,70 +1,70 @@ -#ifndef VARIANT_INL_H_ -#error "Direct inclusion of this file is not allowed, include variant.h" +#ifndef VARIANT_INL_H_ +#error "Direct inclusion of this file is not allowed, include variant.h" // For the sake of sane code completion. #include "variant.h" -#endif - -#include <type_traits> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -namespace NDetail { - -template <class T> -struct TIndexOf<T> -{ - static constexpr size_t Value = std::numeric_limits<size_t>::max(); -}; - -template <class T, class T0, class... Ts> -struct TIndexOf<T, T0, Ts...> -{ - static constexpr size_t Value = std::is_same_v<T, T0> - ? 0 - : 1 + TIndexOf<T, Ts...>::Value; -}; - -template <size_t Index, class... Ts> -struct TVariantFormatter; - -template <size_t Index> -struct TVariantFormatter<Index> -{ - template <class TVariant> - static void Do(TStringBuilderBase* /*builder*/, const TVariant& /*variant*/, TStringBuf /*spec*/) - { } -}; - -template <size_t Index, class T, class... Ts> -struct TVariantFormatter<Index, T, Ts...> -{ - template <class TVariant> - static void Do(TStringBuilderBase* builder, const TVariant& variant, TStringBuf spec) - { - if (variant.index() == Index) { - FormatValue(builder, std::get<Index>(variant), spec); - } else { - TVariantFormatter<Index + 1, Ts...>::Do(builder, variant, spec); - } - } -}; - -} // namespace NDetail - -template <class... Ts> -void FormatValue(TStringBuilderBase* builder, const std::variant<Ts...>& variant, TStringBuf spec) -{ - NDetail::TVariantFormatter<0, Ts...>::Do(builder, variant, spec); -} - -template <class... Ts> -TString ToString(const std::variant<Ts...>& variant) -{ - return ToStringViaBuilder(variant); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT +#endif + +#include <type_traits> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +namespace NDetail { + +template <class T> +struct TIndexOf<T> +{ + static constexpr size_t Value = std::numeric_limits<size_t>::max(); +}; + +template <class T, class T0, class... Ts> +struct TIndexOf<T, T0, Ts...> +{ + static constexpr size_t Value = std::is_same_v<T, T0> + ? 0 + : 1 + TIndexOf<T, Ts...>::Value; +}; + +template <size_t Index, class... Ts> +struct TVariantFormatter; + +template <size_t Index> +struct TVariantFormatter<Index> +{ + template <class TVariant> + static void Do(TStringBuilderBase* /*builder*/, const TVariant& /*variant*/, TStringBuf /*spec*/) + { } +}; + +template <size_t Index, class T, class... Ts> +struct TVariantFormatter<Index, T, Ts...> +{ + template <class TVariant> + static void Do(TStringBuilderBase* builder, const TVariant& variant, TStringBuf spec) + { + if (variant.index() == Index) { + FormatValue(builder, std::get<Index>(variant), spec); + } else { + TVariantFormatter<Index + 1, Ts...>::Do(builder, variant, spec); + } + } +}; + +} // namespace NDetail + +template <class... Ts> +void FormatValue(TStringBuilderBase* builder, const std::variant<Ts...>& variant, TStringBuf spec) +{ + NDetail::TVariantFormatter<0, Ts...>::Do(builder, variant, spec); +} + +template <class... Ts> +TString ToString(const std::variant<Ts...>& variant) +{ + return ToStringViaBuilder(variant); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/library/cpp/yt/misc/variant.h b/library/cpp/yt/misc/variant.h index 27c0a2bc08..a6b6821e1e 100644 --- a/library/cpp/yt/misc/variant.h +++ b/library/cpp/yt/misc/variant.h @@ -1,41 +1,41 @@ -#pragma once - -#include <variant> - -namespace NYT { - -//////////////////////////////////////////////////////////////////////////////// - -namespace NDetail { - -template <class T, class... Ts> -struct TIndexOf; - -} // namespace NDetail - -template <class T, class V> -struct TVariantIndex; - -template <class T, class... Ts> -struct TVariantIndex<T, std::variant<Ts...>> - : std::integral_constant<size_t, NDetail::TIndexOf<T, Ts...>::Value> -{ }; - -template <class T, class V> -constexpr size_t VariantIndexV = TVariantIndex<T, V>::value; - -//////////////////////////////////////////////////////////////////////////////// - -class TStringBuilderBase; - +#pragma once + +#include <variant> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +namespace NDetail { + +template <class T, class... Ts> +struct TIndexOf; + +} // namespace NDetail + +template <class T, class V> +struct TVariantIndex; + +template <class T, class... Ts> +struct TVariantIndex<T, std::variant<Ts...>> + : std::integral_constant<size_t, NDetail::TIndexOf<T, Ts...>::Value> +{ }; + +template <class T, class V> +constexpr size_t VariantIndexV = TVariantIndex<T, V>::value; + +//////////////////////////////////////////////////////////////////////////////// + +class TStringBuilderBase; + +template <class... Ts> +void FormatValue(TStringBuilderBase* builder, const std::variant<Ts...>& variant, TStringBuf spec); + template <class... Ts> -void FormatValue(TStringBuilderBase* builder, const std::variant<Ts...>& variant, TStringBuf spec); - -template <class... Ts> -TString ToString(const std::variant<Ts...>& variant); - -//////////////////////////////////////////////////////////////////////////////// +TString ToString(const std::variant<Ts...>& variant); +//////////////////////////////////////////////////////////////////////////////// + //! A concise way of creating a functor with an overloaded operator(). /*! * Very useful for std::visit-ing variants. For example: @@ -69,8 +69,8 @@ auto Visit(T&& variant, U&&... visitorOverloads) //////////////////////////////////////////////////////////////////////////////// -} // namespace NYT - -#define VARIANT_INL_H_ -#include "variant-inl.h" -#undef VARIANT_INL_H_ +} // namespace NYT + +#define VARIANT_INL_H_ +#include "variant-inl.h" +#undef VARIANT_INL_H_ diff --git a/library/cpp/yt/misc/ya.make b/library/cpp/yt/misc/ya.make index bb76711ddd..76323eb06a 100644 --- a/library/cpp/yt/misc/ya.make +++ b/library/cpp/yt/misc/ya.make @@ -8,7 +8,7 @@ SRCS( ) PEERDIR( - library/cpp/yt/exception + library/cpp/yt/exception ) CHECK_DEPENDENT_DIRS( @@ -21,7 +21,7 @@ CHECK_DEPENDENT_DIRS( ) END() - -RECURSE_FOR_TESTS( - unittests -) + +RECURSE_FOR_TESTS( + unittests +) |