Using std::variant with recursion, without using boost::recursive_wrapper
I'd like to replace boost::variant s with C++17 std::variant and get rid of boost::recursive_wrapper , to remove dependency on boost completely in following code. How may I do that? #include <boost/variant.hpp> #include <type_traits> using v = boost::variant<int, boost::recursive_wrapper<struct s> >; struct s { v val; }; template<template <typename...> class R, typename T, typename ... Ts> auto reduce(T t, Ts ... /*ts*/) { return R<T, Ts...>{t}; } template<typename T, typename F> T adapt(F f) { static_assert(std::is_convertible_v<F, T>, ""); return f; } int main() { int val1 = 42; s val2; auto