OpenShaderDesigner
0.0.1
Loading...
Searching...
No Matches
Include
Utility
Any.h
1
// =====================================================================================================================
2
// Copyright 2024 Medusa Slockbower
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
// =====================================================================================================================
15
16
#ifndef ANY_H
17
#define ANY_H
18
19
#include <
Utility/TemplateUtils.h
>
20
21
template
<
typename
...Ts>
class
Any
;
22
26
template
<
typename
T,
typename
...Rest>
27
class
Any
<T, Rest...> :
public
Any
<Rest...>
28
{
29
// Ensure each element is unique
30
static_assert
(IsUnique<Rest...>);
31
using
ThisType = T;
32
using
BaseType
=
Any
<Rest...>;
33
34
public
:
35
Any
() :
BaseType
() , Value() { }
36
Any
(
const
ThisType& value,
const
Rest&...other) :
BaseType
(other...), Value(value) { }
37
Any
(ThisType&& value, Rest&&...other) :
BaseType
(other...), Value(value) { }
38
Any
(
const
Any
& other) =
default
;
39
Any
(
Any
&& other) =
default
;
40
~Any
() =
default
;
41
42
Any
& operator=(
const
Any
&) =
default
;
43
Any
& operator=(
Any
&&) =
default
;
44
45
operator
ThisType ()
const
{
return
Value; }
46
operator
ThisType& () {
return
Value; }
47
operator
const
ThisType& ()
const
{
return
Value; }
48
operator
ThisType&&() {
return
Value; }
49
operator
ThisType* () {
return
&Value; }
50
operator
const
ThisType* ()
const
{
return
&Value; }
51
52
private
:
53
static
constexpr
size_t
Size =
sizeof
...(Rest);
54
ThisType Value;
55
};
56
57
template
<>
58
class
Any
<> { };
59
60
#endif
//ANY_H
TemplateUtils.h
Provides compile time evaluation utilities for templates and template packs.
Any
Definition
Any.h:21
Generated by
1.11.0