Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <typename F>
- auto foo (F && f)
- {
- // ...
- auto x = std::forward<F>(f)(/* some arguments */);
- // ...
- }
- template <typename F>
- auto foo (F && f)
- {
- using A = typename decltype(std::function{std::forward<F>(f)})::result_type;
- A val { std::forward<F>(f)() };
- return val;
- }
- template <typename F>
- auto bar (F && f)
- {
- using A = typename decltype(std::function{std::forward<F>(f)})::result_type;
- std::vector<A> vect;
- for ( auto i { 0u }; i < 10u ; ++i )
- vect.push_back(std::forward<F>(f)());
- return vect;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement