1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
3 * Ceph - scalable distributed file system
5 * Copyright (C) 2015 XSky <haomai@xsky.com>
7 * Author: Haomai Wang <haomaiwang@gmail.com>
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
16 #ifndef CEPH_MSG_DPDK_CAPTURE_H
17 #define CEPH_MSG_DPDK_CAPTURE_H
21 template <typename T, typename F>
26 capture_impl(capture_impl &) = delete;
27 capture_impl( T && x, F && f )
28 : x{std::forward<T>(x)}, f{std::forward<F>(f)}
31 template <typename ...Ts> auto operator()( Ts&&...args )
32 -> decltype(f( x, std::forward<Ts>(args)... ))
34 return f( x, std::forward<Ts>(args)... );
37 template <typename ...Ts> auto operator()( Ts&&...args ) const
38 -> decltype(f( x, std::forward<Ts>(args)... ))
40 return f( x, std::forward<Ts>(args)... );
44 template <typename T, typename F>
45 capture_impl<T,F> capture( T && x, F && f ) {
46 return capture_impl<T,F>(
47 std::forward<T>(x), std::forward<F>(f) );
50 #endif //CEPH_MSG_DPDK_CAPTURE_H