kraken: utils: add 'StrongType'
I foresee the need to disambiguate a lot of `int`s.
This commit is contained in:
parent
382f374031
commit
b7182826ab
|
@ -2,6 +2,7 @@ add_executable(kraken kraken.cc)
|
||||||
target_link_libraries(kraken PRIVATE common_options)
|
target_link_libraries(kraken PRIVATE common_options)
|
||||||
|
|
||||||
add_subdirectory(csv)
|
add_subdirectory(csv)
|
||||||
|
add_subdirectory(utils)
|
||||||
|
|
||||||
target_link_libraries(kraken PRIVATE
|
target_link_libraries(kraken PRIVATE
|
||||||
csv
|
csv
|
||||||
|
|
3
src/utils/CMakeLists.txt
Normal file
3
src/utils/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
add_library(utils INTERFACE
|
||||||
|
strong-type.hh
|
||||||
|
)
|
18
src/utils/strong-type.hh
Normal file
18
src/utils/strong-type.hh
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace kraken::utils {
|
||||||
|
|
||||||
|
/// A very simple strong type wrapper.
|
||||||
|
template <typename T, typename Tag>
|
||||||
|
struct StrongType {
|
||||||
|
explicit StrongType(T value) : value_(value) {}
|
||||||
|
|
||||||
|
explicit operator T() const {
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
T value_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace kraken::utils
|
Loading…
Reference in a new issue