Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2015, Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 12 | * |
| 13 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 14 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 15 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 18 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 19 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 20 | * |
| 21 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 22 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 23 | * <http://www.gnu.org/licenses/>. |
| 24 | * |
| 25 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 26 | */ |
| 27 | |
| 28 | #ifndef NDN_UTIL_BACKPORTS_HPP |
| 29 | #define NDN_UTIL_BACKPORTS_HPP |
| 30 | |
| 31 | #include "../common.hpp" |
| 32 | |
Davide Pesavento | 96b96af | 2015-09-19 23:00:40 +0200 | [diff] [blame^] | 33 | #ifndef NDN_CXX_HAVE_STD_TO_STRING |
| 34 | #include <boost/lexical_cast.hpp> |
| 35 | #endif |
| 36 | |
Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 37 | namespace ndn { |
| 38 | |
| 39 | #if __cpp_lib_make_unique |
| 40 | using std::make_unique; |
| 41 | #else |
| 42 | template<typename T, typename... Args> |
| 43 | inline unique_ptr<T> |
| 44 | make_unique(Args&&... args) |
| 45 | { |
| 46 | return unique_ptr<T>(new T(std::forward<Args>(args)...)); |
| 47 | } |
| 48 | #endif // __cpp_lib_make_unique |
| 49 | |
Davide Pesavento | 96b96af | 2015-09-19 23:00:40 +0200 | [diff] [blame^] | 50 | #ifdef NDN_CXX_HAVE_STD_TO_STRING |
| 51 | using std::to_string; |
| 52 | #else |
| 53 | template<typename V> |
| 54 | inline std::string |
| 55 | to_string(const V& v) |
| 56 | { |
| 57 | return boost::lexical_cast<std::string>(v); |
| 58 | } |
| 59 | #endif // NDN_CXX_HAVE_STD_TO_STRING |
| 60 | |
Davide Pesavento | 409cc20 | 2015-09-19 14:13:16 +0200 | [diff] [blame] | 61 | } // namespace ndn |
| 62 | |
| 63 | #endif // NDN_UTIL_BACKPORTS_HPP |