LLVM: include/llvm/ADT/ScopeExit.h Source File (original) (raw)

Go to the documentation of this file.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15#ifndef LLVM_ADT_SCOPEEXIT_H

16#define LLVM_ADT_SCOPEEXIT_H

17

19

20#include <type_traits>

21#include

22

23namespace llvm {

25

26template class scope_exit {

27 Callable ExitFunction;

28 bool Engaged = true;

29

30public:

31 template

32 explicit scope_exit(Fp &&F) : ExitFunction(std::forward(F)) {}

33

35 : ExitFunction(std::move(Rhs.ExitFunction)), Engaged(Rhs.Engaged) {

36 Rhs.release();

37 }

41

42 void release() { Engaged = false; }

43

45 if (Engaged)

46 ExitFunction();

47 }

48};

49

50}

51

52

53

54

55

56

57template

58[[nodiscard]] detail::scope_exit<std::decay_t>

62

63}

64

65#endif

Definition ScopeExit.h:26

scope_exit & operator=(scope_exit &&)=delete

scope_exit(Fp &&F)

Definition ScopeExit.h:32

scope_exit(const scope_exit &)=delete

void release()

Definition ScopeExit.h:42

scope_exit & operator=(const scope_exit &)=delete

~scope_exit()

Definition ScopeExit.h:44

scope_exit(scope_exit &&Rhs)

Definition ScopeExit.h:34

A self-contained host- and target-independent arbitrary-precision floating-point software implementat...

This is an optimization pass for GlobalISel generic memory operations.

detail::scope_exit< std::decay_t< Callable > > make_scope_exit(Callable &&F)

Definition ScopeExit.h:59

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Implement std::hash so that hash_code can be used in STL containers.