CeresEngine
0.2.0
A game development framework
Loading...
Searching...
No Matches
Any.hpp
Go to the documentation of this file.
1
//
2
// CeresEngine - A game development framework
3
//
4
// Created by Rogiel Sulzbach.
5
// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6
//
7
8
#pragma once
9
10
#include <any>
11
12
namespace
CeresEngine
{
13
class
Any
:
public
std::any {
14
using
super
= std::any;
15
16
public
:
17
using
super::super;
18
19
public
:
20
explicit
operator
bool
()
const
noexcept
{
return
has_value(); }
21
template
<
typename
T> [[
nodiscard
]]
bool
is
()
const
{
return
getIf<T>
() !=
nullptr
; }
22
23
template
<
typename
T> [[
nodiscard
]]
const
T
&
get
()
const
& {
return
std::any_cast<const T&>(*
this
); }
24
template
<
typename
T> [[
nodiscard
]]
T
&
get
() & {
return
std::any_cast<T&>(*
this
); }
25
template
<
typename
T> [[
nodiscard
]]
T
&&
get
() && {
return
std::any_cast<T&&>(*
this
); }
26
27
template
<
typename
T> [[
nodiscard
]]
const
T
*
getIf
()
const
& {
return
std::any_cast<T>(
this
); }
28
template
<
typename
T> [[
nodiscard
]]
T
*
getIf
() & {
return
std::any_cast<T>(
this
); }
29
};
30
}
// namespace CeresEngine
31
32
//#include "CeresEngine/Foundation/RTTI/Any.hpp"
CeresEngine::Any
Definition
Any.hpp:13
CeresEngine::Any::super
std::any super
Definition
Any.hpp:14
CeresEngine::Any::is
bool is() const
Definition
Any.hpp:21
CeresEngine::Any::get
T && get() &&
Definition
Any.hpp:25
CeresEngine::Any::get
T & get() &
Definition
Any.hpp:24
CeresEngine::Any::getIf
T * getIf() &
Definition
Any.hpp:28
CeresEngine::Any::getIf
const T * getIf() const &
Definition
Any.hpp:27
CeresEngine::Any::get
const T & get() const &
Definition
Any.hpp:23
CeresEngine
Definition
Application.hpp:19
CeresEngine::Button::T
@ T
CeresEngine::hash
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition
Hash.hpp:25
Sources
CeresEngine
Foundation
Any.hpp
Generated by
1.9.8