numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
log_tag_view.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <compare>
23#include <string>
24#include <string_view>
25
27
28namespace num_collect::logging {
29
36public:
42 constexpr explicit log_tag_view(std::string_view name) noexcept
43 : name_(name) {}
44
50 log_tag_view(const log_tag& tag) noexcept // NOLINT
51 : name_(tag.name()) {}
52
58 explicit operator log_tag() const { return log_tag(name_); }
59
65 [[nodiscard]] constexpr auto name() const noexcept -> std::string_view {
66 return name_;
67 }
68
75 constexpr auto operator<=>(const log_tag_view& right) const noexcept
76 -> std::strong_ordering {
77 return this->name().compare(right.name()) <=> 0;
78 }
79
86 constexpr auto operator==(const log_tag_view& right) const noexcept
87 -> bool {
88 return this->name() == right.name();
89 }
90
97 constexpr auto operator!=(const log_tag_view& right) const noexcept
98 -> bool = default;
99
100private:
102 std::string_view name_;
103};
104
105} // namespace num_collect::logging
Class of tags of logs without memory management.
constexpr auto operator<=>(const log_tag_view &right) const noexcept -> std::strong_ordering
Compare two tags.
constexpr log_tag_view(std::string_view name) noexcept
Constructor.
constexpr auto operator!=(const log_tag_view &right) const noexcept -> bool=default
Compare two tags.
log_tag_view(const log_tag &tag) noexcept
Construct (implicit conversion).
constexpr auto name() const noexcept -> std::string_view
Get the name of this tag.
constexpr auto operator==(const log_tag_view &right) const noexcept -> bool
Compare two tags.
Class of tags of logs.
Definition log_tag.h:33
Definition of log_tag class.
STL namespace.