File: scope_guard.h

package info (click to toggle)
android-file-transfer 4.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,496 kB
  • sloc: cpp: 12,909; python: 140; lex: 47; xml: 26; sh: 13; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 337 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef AFTL_MTP_SCOPE_GUARD_H
#define AFTL_MTP_SCOPE_GUARD_H

#include <functional>
#include <mtp/types.h>

namespace mtp
{
	class scope_guard : Noncopyable
	{
		using Callback = std::function<void ()>;
		Callback _callback;

	public:
		scope_guard(Callback && c): _callback(c)
		{ }

		~scope_guard()
		{ _callback(); }
	};

}

#endif