63 _sharedF(std::move(f)),
101 if ( _owning && _ownF ) {
103 _sharedF = std::shared_ptr<F>(std::move(_ownF));
107 else if ( _sharedF ) {
113#ifdef OLB_DEBUG_UNSAFE_FUNCTOR_ARITHMETIC
114 OstreamManager clerr(std::cerr,
"FunctorPtr");
115 clerr <<
"WARNING: Non-owning functor wrapped in std::shared_ptr. Lifetime of composed functor is not guaranteed." << std::endl;
119 _sharedF = std::shared_ptr<F>(
new typename F::identity_functor_type(*_f));
126auto FunctorPtr<F>::toShared() ->
typename std::enable_if<!util::has_identity_functor<G>::value, std::shared_ptr<F>>::type
128 if ( _owning && _ownF ) {
130 _sharedF = std::shared_ptr<F>(std::move(_ownF));
134 else if ( _sharedF ) {
138 OstreamManager clerr(std::cerr,
"FunctorPtr");
139 clerr <<
"ERROR: No identity functor defined. Required to lift functor reference into std::shared_ptr arithmetic." << std::endl;
Smart pointer for managing the various ways of passing functors around.
auto toShared() -> typename std::enable_if< util::has_identity_functor< G >::value, std::shared_ptr< F > >::type
Lifts managed functor reference for usage in std::shared_ptr<F> arithmetic.
std::add_pointer< F >::type operator->() const noexcept
Enable pointer-like access to the exposed functor's members.
FunctorPtr()
Constructor for an empty instance.
bool isOwning() const
Indicates whether a functor instance is both exposed and owned.
std::add_lvalue_reference< F >::type operator*() const
Top level namespace for all of OpenLB.