Skip to content

Commit

Permalink
Added TIdWrapper class for BS_Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mregrock committed May 20, 2024
1 parent 05603fe commit b724f50
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ydb/core/mind/bscontroller/id_wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <concepts>
#include <compare>
#include <ydb/util/generic/string.h>
using TString = TBasicString<char>;

class TGroupIdTag;
template <class T>
concept IntegralType = std::is_integral<T>::value;

concept StringType = std::convertible_to<TString>;
template <typename T, typename Tag>
class TIdWrapper {
private:
T Raw;
public:
TIdWrapper() = default;

~TIdWrapper() = default;

TIdWrapper(const T& value) : Raw(value) {};

TIdWrapper(const TIdWrapper& other) : TIdWrapper(other.Raw);


TIdWrapper& operator=(const T& value) = delete;

void CopyToProto(NProtoBuf::Message *message, void (NProtoBuf::Message::*pfn)(T value)) {
(message->*pfn)(*this);
}

T& operator+=(const T& other) {
return this.Raw += other.Raw;
}


friend TBasicString operator+(const T& first, const T& other) Y_WARN_UNUSED_RESULT {
return first + second;
}

constexpr auto operator<=>(const IntWrapper&) const = default;


};

0 comments on commit b724f50

Please sign in to comment.