22 #ifndef NDN_UTIL_BACKPORTS_HPP 23 #define NDN_UTIL_BACKPORTS_HPP 25 #include "../common.hpp" 27 #ifdef __has_cpp_attribute 28 # define NDN_CXX_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) 30 # define NDN_CXX_HAS_CPP_ATTRIBUTE(x) 0 34 # define NDN_CXX_HAS_INCLUDE(x) __has_include(x) 36 # define NDN_CXX_HAS_INCLUDE(x) 0 39 #if (__cplusplus > 201402L) && NDN_CXX_HAS_CPP_ATTRIBUTE(fallthrough) 40 # define NDN_CXX_FALLTHROUGH [[fallthrough]] 41 #elif NDN_CXX_HAS_CPP_ATTRIBUTE(clang::fallthrough) 42 # define NDN_CXX_FALLTHROUGH [[clang::fallthrough]] 43 #elif NDN_CXX_HAS_CPP_ATTRIBUTE(gnu::fallthrough) 44 # define NDN_CXX_FALLTHROUGH [[gnu::fallthrough]] 45 #elif defined(__GNUC__) && (__GNUC__ >= 7) 46 # define NDN_CXX_FALLTHROUGH __attribute__((fallthrough)) 48 # define NDN_CXX_FALLTHROUGH ((void)0) 54 #ifndef NDN_CXX_HAVE_STD_TO_STRING 55 #include <boost/lexical_cast.hpp> 60 #ifdef NDN_CXX_HAVE_STD_TO_STRING 67 return boost::lexical_cast<std::string>(v);
69 #endif // NDN_CXX_HAVE_STD_TO_STRING 71 #if __cpp_lib_clamp >= 201603 74 template<
typename T,
typename Compare>
76 clamp(
const T& v,
const T& lo,
const T& hi, Compare comp)
78 return comp(v, lo) ? lo : comp(hi, v) ? hi : v;
83 clamp(
const T& v,
const T& lo,
const T& hi)
85 return (v < lo) ? lo : (hi < v) ? hi : v;
87 #endif // __cpp_lib_clamp 89 using ::nonstd::optional;
90 using ::nonstd::bad_optional_access;
92 using ::nonstd::nullopt_t;
94 using ::nonstd::in_place_t;
99 #endif // NDN_UTIL_BACKPORTS_HPP Copyright (c) 2013-2017 Regents of the University of California.
optional< T > make_optional(T const &value)
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
Backport of ostream_joiner from the Library Fundamentals v2 TS.
constexpr const T & clamp(const T &v, const T &lo, const T &hi)
std::string to_string(const V &v)
const nullopt_t nullopt((nullopt_t::init()))
in_place_t in_place(detail::in_place_type_tag< T >=detail::in_place_type_tag< T >())