Skip to content

Instantly share code, notes, and snippets.

@picanumber
Last active March 20, 2016 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save picanumber/48d033904b451621b1cc to your computer and use it in GitHub Desktop.
Save picanumber/48d033904b451621b1cc to your computer and use it in GitHub Desktop.
#define fw(...) ::std::forward<decltype(__VA_ARGS__)>(__VA_ARGS__)
namespace detail
{
/* Implementation ... */
template <class F, class T>
constexpr auto makeO_x(T&& data)
{
return O_x<F, decltype(data)>(fw(data));
}
/* Implementation ... */
template <class... Ts>
constexpr auto _foldr(Ts&&... args)
{
return (fw(args) + ...);
}
}
template <class F, class... Ts>
constexpr decltype(auto) foldr(Ts&&... args)
{
return detail::_foldr(detail::makeO_x<F>(fw(args))...);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment