Autowiring  1.0.3
A C++ Inversion of Control Framework
at_exit.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2015 Leap Motion, Inc. All rights reserved.
2 #pragma once
3 #include RVALUE_HEADER
4 
5 template<class Fn>
6 struct AtExit {
7  AtExit(Fn&& fn) :
8  fn(std::forward<Fn&&>(fn))
9  {}
10 
11  ~AtExit(void) {
12  fn();
13  }
14 
15  Fn fn;
16 };
17 
18 template<class Fn>
19 AtExit<Fn> MakeAtExit(Fn&& fn) {
20  return AtExit<Fn>(std::forward<Fn&&>(fn));
21 }
STL namespace.