1#ifndef DUNE_FEM_COMMON_BINDGUARD_HH
2#define DUNE_FEM_COMMON_BINDGUARD_HH
19 template<
class Object >
22 template<
class... Args >
23 BindGuard ( Object &
object, Args &&... args )
26 object.bind( std::forward< Args >( args )... );
32 void operator() ( Object *
object ) {
object->unbind(); }
35 std::unique_ptr< Object, Deleter > object_;
46 template<
class Object,
class... Args >
47 auto isBindable ( PriorityTag< 1 >, Object &
object, Args &&... args )
48 ->
decltype( std::declval< Object & >().bind( std::declval< Args >()... ), std::true_type() );
50 template<
class Object,
class... Args >
51 auto isBindable ( PriorityTag< 0 >, Object &
object, Args &&... args )
56 template<
class Object,
class... Args >
58 :
public decltype( Impl::isBindable( PriorityTag< 42 >(), std::declval< Object & >(), std::declval< Args >()... ) )
66 template<
class Object,
class... Args >
67 inline static auto bindGuard ( Object &
object, Args &&... args )
68 -> std::enable_if_t< isBindable< Object, Args... >::value, BindGuard< Object > >
70 return BindGuard< Object >(
object, std::forward< Args >( args )... );
73 template< std::size_t... i,
class Objects,
class... Args >
74 inline static auto bindGuard ( std::index_sequence< i... >, Objects objects, Args &&... args )
75 -> std::tuple<
decltype( bindGuard( std::declval< std::tuple_element_t< i, Objects > >(), std::declval< Args >()... ) )... >
78 return std::make_tuple( bindGuard( std::get< i >( objects ), args... )... );
81 template<
class... Object,
class... Args >
82 inline static auto bindGuard ( std::tuple< Object &... > objects, Args &&... args )
83 ->
decltype( bindGuard( std::index_sequence_for< Object... >(), objects, std::forward< Args >( args )... ) )
85 return bindGuard( std::index_sequence_for< Object... >(), objects, std::forward< Args >( args )... );
Dune namespace.
Definition: alignedallocator.hh:13
Utilities for type computations, constraining overloads, ...