1<!-- Copyright 2018 Paul Fultz II 2 Distributed under the Boost Software License, Version 1.0. 3 (http://www.boost.org/LICENSE_1_0.txt) 4--> 5 6Polymorphic constructors 7======================== 8 9Writing polymorphic constructors(such as `make_tuple`) is a boilerplate that 10has to be written over and over again for template classes: 11 12 template <class T> 13 struct unwrap_refwrapper 14 { 15 typedef T type; 16 }; 17 18 template <class T> 19 struct unwrap_refwrapper<std::reference_wrapper<T>> 20 { 21 typedef T& type; 22 }; 23 24 template <class T> 25 struct unwrap_ref_decay 26 : unwrap_refwrapper<typename std::decay<T>::type> 27 {}; 28 29 template <class... Types> 30 std::tuple<typename unwrap_ref_decay<Types>::type...> make_tuple(Types&&... args) 31 { 32 return std::tuple<typename unwrap_ref_decay<Types>::type...>(std::forward<Types>(args)...); 33 } 34 35The [`construct`](include/boost/hof/construct) function takes care of all this boilerplate, and the above can be simply written like this: 36 37 BOOST_HOF_STATIC_FUNCTION(make_tuple) = construct<std::tuple>(); 38