rsl 1.1.0
ROS Support Library
Loading...
Searching...
No Matches
strong_type.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <utility>
4
5namespace rsl {
6
15template <typename T, typename Tag>
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