// // RNBO_Utils.h // // Created by Rob Sussman on 8/4/15. // // #ifndef _RNBO_Utils_H_ #define _RNBO_Utils_H_ #include namespace RNBO { // implementation of make_unique() // taken from: https://isocpp.org/files/papers/N3656.txt // linked to from: http://stackoverflow.com/questions/7038357/make-unique-and-perfect-forwarding /** * @private */ template struct _Unique_if { typedef std::unique_ptr _Single_object; }; /** * @private */ template struct _Unique_if { typedef std::unique_ptr _Unknown_bound; }; /** * @private */ template struct _Unique_if { typedef void _Known_bound; }; /** * @private */ template typename _Unique_if::_Single_object make_unique(Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); } /** * @private */ template typename _Unique_if::_Unknown_bound make_unique(size_t n) { typedef typename std::remove_extent::type U; return std::unique_ptr(new U[n]()); } template typename _Unique_if::_Known_bound make_unique(Args&&...) = delete; // helper template prevents single-argument universal-reference constructor from acting like the copy constructor // see: http://ericniebler.com/2013/08/07/universal-references-and-the-copy-constructo/ template using disable_if_same_or_derived = typename std::enable_if::type>::value>::type; } // namespace RNBO #endif // #ifndef _RNBO_Utils_H_