Sha256: 95643cc5a858035980061072e41b2eb8a3ec1f58f929c6752065d5dedd22a525
Contents?: true
Size: 1.35 KB
Versions: 10
Compression:
Stored size: 1.35 KB
Contents
// Copyright (c) 2020 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_JSON_PEGTL_CONTRIB_INTERNAL_SET_STACK_GUARD_HPP #define TAO_JSON_PEGTL_CONTRIB_INTERNAL_SET_STACK_GUARD_HPP #include <set> #include <utility> #include "../../config.hpp" namespace TAO_JSON_PEGTL_NAMESPACE::internal { template< typename... Cs > class set_stack_guard { public: template< typename... Ts > set_stack_guard( std::set< Cs... >& set, Ts&&... ts ) : m_i( set.emplace( std::forward< Ts >( ts )... ) ), m_s( set ) {} set_stack_guard( set_stack_guard&& ) = delete; set_stack_guard( const set_stack_guard& ) = delete; void operator=( set_stack_guard&& ) = delete; void operator=( const set_stack_guard& ) = delete; ~set_stack_guard() { if( m_i.second ) { m_s.erase( m_i.first ); } } explicit operator bool() const noexcept { return m_i.second; } private: const std::pair< typename std::set< Cs... >::iterator, bool > m_i; std::set< Cs... >& m_s; }; template< typename... Cs > set_stack_guard( std::set< Cs... >&, const typename std::set< Cs... >::value_type& ) -> set_stack_guard< Cs... >; } // namespace TAO_JSON_PEGTL_NAMESPACE::internal #endif
Version data entries
10 entries across 10 versions & 1 rubygems