// eventpp library // Copyright (C) 2018 Wang Qi (wqking) // Github: https://github.com/wqking/eventpp // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef ARGUMENTADAPTER_H_566280692673 #define ARGUMENTADAPTER_H_566280692673 #include namespace eventpp { namespace adapter_internal_ { template struct StaticCast { template static T cast(U && value) { return static_cast(value); } }; template struct StaticCast > { template static std::shared_ptr cast(U && value) { return std::static_pointer_cast(value); } }; template struct IsSharedPtr { enum { value = false }; }; template struct IsSharedPtr > { enum { value = true }; }; template struct IsAnySharedPtr { enum { value = false }; }; template struct IsAnySharedPtr { enum { value = IsSharedPtr::value || IsAnySharedPtr::value }; }; } //namespace adapter_internal_ template struct ArgumentAdapter; template struct ArgumentAdapter < Func, R(Args...), typename std::enable_if::value>::type > { explicit ArgumentAdapter(Func f) : func(std::move(f)) { } template void operator() (A &&...args) { func(std::forward(static_cast(args))...); } Func func; }; template struct ArgumentAdapter < Func, R(Args...), typename std::enable_if::value>::type > { explicit ArgumentAdapter(Func f) : func(std::move(f)) { } template void operator() (A &&...args) { func(std::forward(adapter_internal_::StaticCast::cast(args))...); } Func func; }; template