FuncSketch
Loading...
Searching...
No Matches
any.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 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 <any>
23#include <type_traits>
24#include <utility>
25
26namespace func_sketch::utilities {
27
33class Any {
34public:
40 template <typename T>
41 requires(!std::is_same_v<std::decay_t<T>, Any>)
42 explicit Any(T&& value) : value_(std::forward<T>(value)) {}
43
50 template <typename T>
51 [[nodiscard]] const T& get() const {
52 return std::any_cast<const T&>(value_);
53 }
54
55private:
57 std::any value_;
58};
59
60} // namespace func_sketch::utilities
const T & get() const
Get the stored value.
Definition any.h:51
std::any value_
Stored value.
Definition any.h:57
Any(T &&value)
Constructor.
Definition any.h:42