OpenVPN 3 Core Library
Loading...
Searching...
No Matches
cleanup.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12#ifndef OPENVPN_COMMON_CLEANUP_H
13#define OPENVPN_COMMON_CLEANUP_H
14
15#include <utility>
16
17namespace openvpn {
18
19template <typename F>
21{
22 public:
23 CleanupType(F method) noexcept
24 : clean(std::move(method))
25 {
26 }
27
28 CleanupType(CleanupType &&) = default;
29
31 {
32 clean();
33 }
34
35 private:
36 CleanupType(const CleanupType &) = delete;
37 CleanupType &operator=(const CleanupType &) = delete;
38
40};
41
42template <typename F>
43inline CleanupType<F> Cleanup(F method) noexcept
44{
45 return CleanupType<F>(std::move(method));
46}
47
48} // namespace openvpn
49
50#endif
CleanupType & operator=(const CleanupType &)=delete
CleanupType(CleanupType &&)=default
CleanupType(const CleanupType &)=delete
CleanupType(F method) noexcept
Definition cleanup.hpp:23
Support deferred server-side state creation when client connects.
Definition ovpncli.cpp:95
CleanupType< F > Cleanup(F method) noexcept
Definition cleanup.hpp:43