22 #ifndef NDN_UTIL_BACKPORTS_HPP
23 #define NDN_UTIL_BACKPORTS_HPP
25 #include "../common.hpp"
27 #ifndef NDN_CXX_HAVE_STD_TO_STRING
28 #include <boost/lexical_cast.hpp>
35 #if __cpp_lib_make_unique
38 template<
typename T,
typename ...Args>
42 return unique_ptr<T>(
new T(std::forward<Args>(args)...));
44 #endif // __cpp_lib_make_unique
46 #ifdef NDN_CXX_HAVE_STD_TO_STRING
53 return boost::lexical_cast<std::string>(v);
55 #endif // NDN_CXX_HAVE_STD_TO_STRING
57 #if __cpp_lib_clamp >= 201603
60 template<
typename T,
typename Compare>
62 clamp(
const T& v,
const T& lo,
const T& hi, Compare comp)
64 return comp(v, lo) ? lo : comp(hi, v) ? hi : v;
69 clamp(
const T& v,
const T& lo,
const T& hi)
71 return (v < lo) ? lo : (hi < v) ? hi : v;
73 #endif // __cpp_lib_clamp
79 #endif // NDN_UTIL_BACKPORTS_HPP
Copyright (c) 2013-2016 Regents of the University of California.
unique_ptr< T > make_unique(Args &&...args)
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
Copyright (c) 2013-2016 Regents of the University of California.
constexpr const T & clamp(const T &v, const T &lo, const T &hi)
std::string to_string(const V &v)