Btk
scope.hpp
1
#if !defined(_BTKIMPL_SCOPE_HPP_)
2
#define _BTKIMPL_SCOPE_HPP_
3
#include <SDL2/SDL_stdinc.h>
4
#define Btk_defer Btk::Impl::ScopeGuard __GUARD__ = [&]()
5
namespace
Btk
{
6
namespace
Impl{
7
//ScopeGuard
8
template
<
class
T>
9
struct
ScopeGuard
{
10
inline
ScopeGuard
(T &&f):fn(f){}
11
inline
~
ScopeGuard
(){
12
fn();
13
}
14
T &fn;
15
};
16
//Data from SDL lib
17
struct
SDLScopePtr
{
18
SDLScopePtr
(
void
*dat):data(dat){};
19
SDLScopePtr
(
const
SDLScopePtr
& ) =
delete
;
20
SDLScopePtr
(){
21
SDL_free(data);
22
}
23
void
*data;
24
};
25
};
26
using
Impl::SDLScopePtr
;
27
};
28
29
#endif // _BTKIMPL_SCOPE_HPP_
Btk
This header include many useful containers.
Definition:
async.hpp:7
Btk::Impl::SDLScopePtr
Definition:
scope.hpp:17
Btk::Impl::ScopeGuard
Definition:
scope.hpp:9
include
Btk
impl
scope.hpp
Generated by
1.8.13