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
12namespace 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"
Definition Any.hpp:13
std::any super
Definition Any.hpp:14
bool is() const
Definition Any.hpp:21
T && get() &&
Definition Any.hpp:25
T & get() &
Definition Any.hpp:24
T * getIf() &
Definition Any.hpp:28
const T * getIf() const &
Definition Any.hpp:27
const T & get() const &
Definition Any.hpp:23
Definition Application.hpp:19
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25