to_std_function.hpp
1 #ifndef PRE_FUNCTIONAL_TO_STD_FUNCTION_HPP
2 #define PRE_FUNCTIONAL_TO_STD_FUNCTION_HPP
3 
4 #include <functional>
5 #include <pre/type_traits/function_traits.hpp>
6 
7 namespace pre { namespace functional {
8 
9 
10  /* Creates an std::function object from the given lambda, member function, free standing function
11  * @t the lambda/[member]function to transform into std::function.
12  * @return An [std::function](http://en.cppreference.com/w/cpp/utility/functional/function) of the given functor/function.
13  */
14  template <class T>
15  auto to_std_function (T t) -> typename type_traits::function_traits<T>::function_type {
16  return typename type_traits::function_traits<T>::function_type(t);
17  }
18 
19 }}
20 
21 #endif /*PRE_FUNCTIONAL_TO_STD_FUNCTION_HPP*/