forked from Alepha/Alepha
Add a simple commandline parser example.
Also cleaned up a few files. Since these were pulled from various scratch repos from informal ISO discussions over the years, they don't quite line up. This at least gets everything building again.
This commit is contained in:
20
AutoRAII.h
20
AutoRAII.h
@ -79,6 +79,26 @@ namespace Alepha::Hydrogen
|
||||
decltype( auto ) operator->() const { return value; }
|
||||
};
|
||||
|
||||
template< typename Dtor >
|
||||
class AutoRAII< void, Dtor > : boost::noncopyable
|
||||
{
|
||||
private:
|
||||
Dtor dtor;
|
||||
|
||||
public:
|
||||
~AutoRAII()
|
||||
{
|
||||
if constexpr( std::is_same_v< Dtor, std::function< void () > > )
|
||||
{
|
||||
if( dtor == nullptr ) return;
|
||||
}
|
||||
dtor();
|
||||
}
|
||||
|
||||
template< typename Ctor >
|
||||
explicit AutoRAII( Ctor ctor, Dtor dtor ) : dtor( std::move( dtor ) ) { ctor(); }
|
||||
};
|
||||
|
||||
template< typename Ctor, typename Dtor >
|
||||
explicit AutoRAII( Ctor ctor, Dtor ) -> AutoRAII< decltype( ctor() ), Dtor >;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user