# OpenShaderDesigner: Include/Utility/Any.h Source File

Loading...
Searching...
No Matches
Any.h
// =====================================================================================================================
// Copyright 2024 Medusa Slockbower
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =====================================================================================================================
#ifndef ANY_H
#define ANY_H
#include <Utility/TemplateUtils.h>
template<typename...Ts> class Any;
template<typename T, typename...Rest>
class Any<T, Rest...> : public Any<Rest...>
{
// Ensure each element is unique
static_assert(IsUnique<Rest...>);
using ThisType = T;
using BaseType = Any<Rest...>;
public:
Any() : BaseType() , Value() { }
Any(const ThisType& value, const Rest&...other) : BaseType(other...), Value(value) { }
Any(ThisType&& value, Rest&&...other) : BaseType(other...), Value(value) { }
Any(const Any& other) = default;
Any(Any&& other) = default;
~Any() = default;
Any& operator=(const Any&) = default;
Any& operator=(Any&&) = default;
operator ThisType () const { return Value; }
operator ThisType& () { return Value; }
operator const ThisType& () const { return Value; }
operator ThisType&&() { return Value; }
operator ThisType* () { return &Value; }
operator const ThisType* () const { return &Value; }
private:
static constexpr size_t Size = sizeof...(Rest);
ThisType Value;
};
template<>
class Any<> { };
#endif //ANY_H
TemplateUtils.h
Provides compile time evaluation utilities for templates and template packs.
Any
Definition Any.h:21