X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fcommon%2Fbackport14.h;fp=src%2Fceph%2Fsrc%2Fcommon%2Fbackport14.h;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=3e6505d468d31fdfc6afe6da0f75b49ec88b1058;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/common/backport14.h b/src/ceph/src/common/backport14.h deleted file mode 100644 index 3e6505d..0000000 --- a/src/ceph/src/common/backport14.h +++ /dev/null @@ -1,128 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2004-2006 Sage Weil - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#include -#include - -#ifndef CEPH_COMMON_BACKPORT14_H -#define CEPH_COMMON_BACKPORT14_H - -// Library code from C++14 that can be implemented in C++11. - -namespace ceph { -template -using remove_extent_t = typename std::remove_extent::type; -template -using remove_reference_t = typename std::remove_reference::type; -template -using result_of_t = typename std::result_of::type; -template -using decay_t = typename std::decay::type; - -namespace _backport14 { -template -struct uniquity { - using datum = std::unique_ptr; -}; - -template -struct uniquity { - using array = std::unique_ptr; -}; - -template -struct uniquity { - using verboten = void; -}; - -template -inline typename uniquity::datum make_unique(Args&&... args) { - return std::unique_ptr(new T(std::forward(args)...)); -} - -template -inline typename uniquity::array make_unique(std::size_t n) { - return std::unique_ptr(new remove_extent_t[n]()); -} - -template -typename uniquity::verboten -make_unique(Args&&...) = delete; - -// The constexpr variant of std::max(). -template -constexpr const T& max(const T& a, const T& b) { - return a < b ? b : a; -} -} // namespace _backport14 - -namespace _backport17 { -template -constexpr auto size(const C& c) -> decltype(c.size()) { - return c.size(); -} - -template -constexpr std::size_t size(const T (&array)[N]) noexcept { - return N; -} - -/// http://en.cppreference.com/w/cpp/utility/functional/not_fn -// this implementation uses c++14's result_of_t (above) instead of the c++17 -// invoke_result_t, and so may not behave correctly when SFINAE is required -template -class not_fn_result { - using DecayF = decay_t; - DecayF fn; - public: - explicit not_fn_result(F&& f) : fn(std::forward(f)) {} - not_fn_result(not_fn_result&& f) = default; - not_fn_result(const not_fn_result& f) = default; - - template - auto operator()(Args&&... args) & - -> decltype(!std::declval>()) { - return !fn(std::forward(args)...); - } - template - auto operator()(Args&&... args) const& - -> decltype(!std::declval>()) { - return !fn(std::forward(args)...); - } - - template - auto operator()(Args&&... args) && - -> decltype(!std::declval>()) { - return !std::move(fn)(std::forward(args)...); - } - template - auto operator()(Args&&... args) const&& - -> decltype(!std::declval>()) { - return !std::move(fn)(std::forward(args)...); - } -}; - -template -not_fn_result not_fn(F&& fn) { - return not_fn_result(std::forward(fn)); -} - -} // namespace _backport17 -using _backport14::make_unique; -using _backport17::size; -using _backport14::max; -using _backport17::not_fn; -} // namespace ceph - -#endif // CEPH_COMMON_BACKPORT14_H