/usr/include/globjects/base/FunctionCall.inl is in libglobjects-dev 1.0.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | #pragma once
#include <cstddef>
#include <type_traits>
#include <utility>
namespace
{
// http://stackoverflow.com/questions/687490/how-do-i-expand-a-tuple-into-variadic-template-functions-arguments
template<size_t N>
struct ApplyHelper
{
template<typename F, typename T, typename... A>
static inline auto apply(F && f, T && t, A &&... a)
-> decltype(
ApplyHelper<N-1>::apply(
std::forward<F>(f),
std::forward<T>(t),
std::get<N-1>(std::forward<T>(t)),
std::forward<A>(a)...
)
)
{
return ApplyHelper<N-1>::apply(
std::forward<F>(f),
std::forward<T>(t),
std::get<N-1>(std::forward<T>(t)),
std::forward<A>(a)...
);
}
};
template<>
struct ApplyHelper<0>
{
template<typename F, typename T, typename... A>
static inline auto apply(F && f, T &&, A &&... a)
-> decltype(
std::forward<F>(f)(std::forward<A>(a)...)
)
{
return std::forward<F>(f)(
std::forward<A>(a)...
);
}
};
template<typename F, typename T>
inline auto apply(F && f, T && t)
-> decltype(
ApplyHelper<std::tuple_size<typename std::decay<T>::type>::value>::apply(
std::forward<F>(f),
std::forward<T>(t)
)
)
{
return ApplyHelper<std::tuple_size<typename std::decay<T>::type>::value>::apply(
std::forward<F>(f),
std::forward<T>(t)
);
}
} // namespace
namespace globjects
{
template <typename... Arguments>
FunctionCall<Arguments...>::FunctionCall(FunctionPointer function, Arguments... arguments)
: m_functionPointer(function)
, m_function(function)
, m_arguments(arguments...)
{
}
template <typename... Arguments>
FunctionCall<Arguments...>::FunctionCall()
{
}
template <typename... Arguments>
void FunctionCall<Arguments...>::operator()()
{
apply(m_function, m_arguments);
}
template <typename... Arguments>
void * FunctionCall<Arguments...>::identifier() const
{
return *reinterpret_cast<void**>(&m_functionPointer);
}
} // namespace globjects
|