-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_type.hpp
More file actions
38 lines (34 loc) · 790 Bytes
/
data_type.hpp
File metadata and controls
38 lines (34 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <string_view>
#include <type_traits>
namespace atom
{
class data {};
template <const char* key_value, typename type>
class data_type : public data
{
public:
data_type() = default;
template <typename value_type, typename = std::enable_if_t<
std::is_constructible_v<type, std::remove_cv_t<std::decay_t<value_type>>>
>>
data_type(value_type&& value_)
: value_ { std::forward<value_type>(value_) }
{ }
[[nodiscard]]std::string_view key() const noexcept
{
return key_;
}
[[nodiscard]]type& value() noexcept
{
return value_;
}
[[nodiscard]]const type& value() const noexcept
{
return value_;
}
private:
const char* key_ { key_value };
type value_;
};
}