NasNas
An intuitive and beginner friendly 2D game framework for C++
include
NasNas
core
AppAccess.hpp
1
5
#pragma once
6
7
#include <type_traits>
8
9
namespace
ns
{
10
// forward declaration of App type
11
class
App;
12
13
namespace
detail {
14
class
AppComponent
{
15
public
:
16
static
App
* app;
17
};
18
}
19
23
template
<
typename
T=App,
typename
= std::enable_if<std::is_base_of_v<App, T>>>
24
class
AppAccess
:
protected
detail::AppComponent
{
25
public
:
26
static
constexpr
auto
app() -> T& {
27
if
constexpr(std::is_same_v<App, T>)
28
return
*AppComponent::app;
29
else
30
return
*
static_cast<
T*
>
(AppComponent::app);
31
}
32
};
33
34
}
ns::AppAccess
Definition:
AppAccess.hpp:24
ns::detail::AppComponent
Definition:
AppAccess.hpp:14
ns::App
Definition:
App.hpp:39
ns
Generated by
1.8.13