rsl  1.1.0
ROS Support Library
strong_type.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
4 
5 namespace rsl {
6 
15 template <typename T, typename Tag>
16 class StrongType {
17  T value_;
18 
19  public:
23  constexpr explicit StrongType(T value) : value_(std::move(value)) {}
24 
28  [[nodiscard]] constexpr T& get() { return value_; }
29 
33  [[nodiscard]] constexpr const T& get() const { return value_; }
34 
38  [[nodiscard]] constexpr explicit operator T() const { return value_; }
39 };
40 
41 } // namespace rsl
Class template for creating strong type aliases.
Definition: strong_type.hpp:16
constexpr T & get()
Get non-const reference to underlying value.
Definition: strong_type.hpp:28
constexpr StrongType(T value)
Construct from any type.
Definition: strong_type.hpp:23
constexpr const T & get() const
Get const reference to underlying value.
Definition: strong_type.hpp:33