-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manually merge PR from wravery, closes #309
- Loading branch information
Showing
3 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey | ||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ | ||
|
||
#ifndef TAO_PEGTL_INTERNAL_UNWIND_GUARD_HPP | ||
#define TAO_PEGTL_INTERNAL_UNWIND_GUARD_HPP | ||
|
||
#include "../config.hpp" | ||
|
||
#include <optional> | ||
#include <utility> | ||
|
||
namespace TAO_PEGTL_NAMESPACE::internal | ||
{ | ||
template< typename Unwind > | ||
struct unwind_guard | ||
{ | ||
explicit unwind_guard( Unwind&& unwind_impl ) | ||
: unwind( std::move( unwind_impl ) ) | ||
{} | ||
|
||
~unwind_guard() | ||
{ | ||
if( unwind ) { | ||
( *unwind )(); | ||
} | ||
} | ||
|
||
unwind_guard( const unwind_guard& ) = delete; | ||
unwind_guard( unwind_guard&& ) noexcept = delete; | ||
|
||
unwind_guard& operator=( const unwind_guard& ) = delete; | ||
unwind_guard& operator=( unwind_guard&& ) noexcept = delete; | ||
|
||
std::optional< Unwind > unwind; | ||
}; | ||
|
||
} // namespace TAO_PEGTL_NAMESPACE::internal | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters