Using std::function<> for callbacks with C++11

This commit is contained in:
Pavel Kirienko
2014-03-28 02:17:00 +04:00
parent c769626eef
commit 062170c995
4 changed files with 59 additions and 2 deletions
@@ -5,13 +5,26 @@
#pragma once
#include <cassert>
#include <uavcan/impl_constants.hpp>
#include <uavcan/node/generic_subscriber.hpp>
#if !defined(UAVCAN_CPP_VERSION) || !defined(UAVCAN_CPP11)
# error UAVCAN_CPP_VERSION
#endif
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
# include <functional>
#endif
namespace uavcan
{
template <typename DataType_,
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
typename Callback = std::function<void (const ReceivedDataStructure<DataType_>&)>,
#else
typename Callback = void (*)(const ReceivedDataStructure<DataType_>&),
#endif
unsigned int NumStaticReceivers = 2,
unsigned int NumStaticBufs = 1>
class Subscriber : public GenericSubscriber<DataType_, DataType_,