// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- /* * Ceph - scalable distributed file system * * Copyright (C) 2015 XSky * * Author: Haomai Wang * * This is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software * Foundation. See file COPYING. * */ #ifndef CEPH_MSG_DPDK_CAPTURE_H #define CEPH_MSG_DPDK_CAPTURE_H #include template class capture_impl { T x; F f; public: capture_impl(capture_impl &) = delete; capture_impl( T && x, F && f ) : x{std::forward(x)}, f{std::forward(f)} {} template auto operator()( Ts&&...args ) -> decltype(f( x, std::forward(args)... )) { return f( x, std::forward(args)... ); } template auto operator()( Ts&&...args ) const -> decltype(f( x, std::forward(args)... )) { return f( x, std::forward(args)... ); } }; template capture_impl capture( T && x, F && f ) { return capture_impl( std::forward(x), std::forward(f) ); } #endif //CEPH_MSG_DPDK_CAPTURE_H