zookeeper-cpp
ZooKeeper Client for C++
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
zk::strong_id< TReal, TId > Struct Template Reference

Base type for creating strong ID types. More...

#include <zk/types.hpp>

Public Types

using value_type = TId
 The representation type of this ID. More...
 

Public Member Functions

 strong_id () noexcept=default
 Default construct the ID. More...
 
constexpr strong_id (value_type value) noexcept
 Construct this instance with the given value. More...
 
constexpr value_type get () const noexcept
 Get the value of this ID. More...
 
constexpr operator value_type () noexcept
 Get the value of this ID. More...
 
TReal & operator++ ()
 
TReal operator++ (int)
 
TReal & operator-- ()
 
TReal operator-- (int)
 

Public Attributes

value_type value
 Underlying value of this ID. More...
 

Detailed Description

template<typename TReal, typename TId>
struct zk::strong_id< TReal, TId >

Base type for creating strong ID types.

These behave similar to a typedef, but do not allow conversion between different TReal types, even if they share the same TId. This makes attempting to use a version instead of an acl_version in client::set_acl a compile-time failure instead of throwing a bad_version at run-time.

Template Parameters
TRealThe "real" leaf type of this ID.
TIdThe representation type of this ID. This must be some form of integer and is usually std::int32_t (as in basic_version).
See also
version
child_version
acl_version
transaction_id

Definition at line 28 of file types.hpp.

Member Typedef Documentation

template<typename TReal, typename TId>
using zk::strong_id< TReal, TId >::value_type = TId

The representation type of this ID.

Definition at line 31 of file types.hpp.

Constructor & Destructor Documentation

template<typename TReal, typename TId>
zk::strong_id< TReal, TId >::strong_id ( )
defaultnoexcept

Default construct the ID.

This probably leaves value uninitialized (depending on the constructor of value_type).

template<typename TReal, typename TId>
constexpr zk::strong_id< TReal, TId >::strong_id ( value_type  value)
inlineexplicitnoexcept

Construct this instance with the given value.

Definition at line 41 of file types.hpp.

Member Function Documentation

template<typename TReal, typename TId>
constexpr value_type zk::strong_id< TReal, TId >::get ( ) const
inlinenoexcept

Get the value of this ID.

Definition at line 46 of file types.hpp.

template<typename TReal, typename TId>
constexpr zk::strong_id< TReal, TId >::operator value_type ( )
inlineexplicitnoexcept

Get the value of this ID.

See also
get

Definition at line 51 of file types.hpp.

template<typename TReal, typename TId>
TReal& zk::strong_id< TReal, TId >::operator++ ( )
inline

Increment the value of this ID by 1. This can be useful for maintaining caches after updates without getting the result. For example, a transaction with a version-checked set operation knows the next version of the entry will be only one more.

Definition at line 57 of file types.hpp.

template<typename TReal, typename TId>
TReal& zk::strong_id< TReal, TId >::operator-- ( )
inline

Decrement the value of this ID by 1. This operation is probably not useful, but is included for completeness.

Definition at line 74 of file types.hpp.

Member Data Documentation

template<typename TReal, typename TId>
value_type zk::strong_id< TReal, TId >::value

Underlying value of this ID.

Definition at line 34 of file types.hpp.


The documentation for this struct was generated from the following file: