18namespace sharg::detail
30 id_pair(id_pair
const &) =
default;
31 id_pair & operator=(id_pair
const &) =
default;
32 id_pair(id_pair &&) =
default;
33 id_pair & operator=(id_pair &&) =
default;
37 id_pair(
char const short_id) : short_id{short_id}
45 id_pair(
char const short_id,
std::string long_id) : short_id{short_id}, long_id{
std::
move(long_id)}
51 friend bool operator==(id_pair
const & lhs, id_pair
const & rhs)
53 return (!lhs.empty_short_id() && lhs.short_id == rhs.short_id)
54 || (!lhs.empty_long_id() && lhs.long_id == rhs.long_id);
60 friend bool operator==(id_pair
const & lhs,
char const & rhs)
62 return !lhs.empty_short_id() && lhs.short_id == rhs;
68 friend bool operator==(id_pair
const & lhs,
std::string const & rhs)
70 return !lhs.empty_long_id() && lhs.long_id == rhs;
74 bool empty_short_id() const noexcept
76 return empty(short_id);
80 bool empty_long_id() const noexcept
82 return empty(long_id);
86 bool empty() const noexcept
88 return empty_short_id() && empty_long_id();
92 bool has_both_ids() const noexcept
94 return !empty_short_id() && !empty_long_id();
98 template <
typename id_type>
99 static bool empty(id_type
const &
id)
noexcept;
109 template <
typename id_type>
113 template <
typename id_type>
126struct hash<sharg::detail::id_pair>
129 size_t operator()(sharg::detail::id_pair
const & value)
const noexcept
133 return h1 ^ (
h2 << 1);
139namespace sharg::detail
142template <
typename id_type>
143inline bool id_pair::empty(id_type
const &
id)
noexcept
153template <
typename id_type>
157 return used_ids.
end();
160 [&
id](id_pair
const & pair)
166template <
typename id_type>
169 return find(used_ids,
id) != used_ids.
end();