X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FReplaceable.h;h=f96aac6087adeb16ccfbf671aa969315ecfdac62;hp=bdd5519e098d87cb2cb57142651082fc749ff08a;hb=0c20289b724cf462078cf70d0ea1487f67b45fa8;hpb=efc4ca1ecfa090028b6260f7d77373ebd0aa8b45 diff --git a/folly/Replaceable.h b/folly/Replaceable.h index bdd5519e..f96aac60 100644 --- a/folly/Replaceable.h +++ b/folly/Replaceable.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-present Facebook, Inc. + * Copyright 2017-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,9 +21,10 @@ #include #include -#include +#include #include #include +#include /** * An instance of `Replaceable` wraps an instance of `T`. @@ -357,10 +358,6 @@ struct is_constructible_from_replaceable std::is_constructible&>::value || std::is_constructible&&>::value> {}; -template -constexpr bool is_constructible_from_replaceable_v{ - is_constructible_from_replaceable::value}; - template struct is_convertible_from_replaceable : std::integral_constant< @@ -369,10 +366,6 @@ struct is_convertible_from_replaceable std::is_convertible&&, T>::value || std::is_convertible&, T>::value || std::is_convertible&&, T>::value> {}; - -template -constexpr bool is_convertible_from_replaceable_v{ - is_convertible_from_replaceable::value}; } // namespace replaceable_detail // Type trait template to statically test whether a type is a specialization of @@ -383,9 +376,6 @@ struct is_replaceable : std::false_type {}; template struct is_replaceable> : std::true_type {}; -template -constexpr bool is_replaceable_v{is_replaceable::value}; - // Function to make a Replaceable with a type deduced from its input template constexpr Replaceable> make_replaceable(T&& t) { @@ -461,7 +451,7 @@ class alignas(T) Replaceable template < class... Args, std::enable_if_t::value, int> = 0> - constexpr explicit Replaceable(in_place_t, Args&&... args) + FOLLY_CPP14_CONSTEXPR explicit Replaceable(in_place_t, Args&&... args) // clang-format off noexcept(std::is_nothrow_constructible::value) // clang-format on @@ -475,7 +465,7 @@ class alignas(T) Replaceable std::enable_if_t< std::is_constructible, Args&&...>::value, int> = 0> - constexpr explicit Replaceable( + FOLLY_CPP14_CONSTEXPR explicit Replaceable( in_place_t, std::initializer_list il, Args&&... args) @@ -497,7 +487,7 @@ class alignas(T) Replaceable !std::is_same, std::decay_t>::value && std::is_convertible::value, int> = 0> - constexpr /* implicit */ Replaceable(U&& other) + FOLLY_CPP14_CONSTEXPR /* implicit */ Replaceable(U&& other) // clang-format off noexcept(std::is_nothrow_constructible::value) // clang-format on @@ -513,7 +503,7 @@ class alignas(T) Replaceable !std::is_same, std::decay_t>::value && !std::is_convertible::value, int> = 0> - explicit constexpr Replaceable(U&& other) + FOLLY_CPP14_CONSTEXPR explicit Replaceable(U&& other) // clang-format off noexcept(std::is_nothrow_constructible::value) // clang-format on @@ -525,8 +515,9 @@ class alignas(T) Replaceable class U, std::enable_if_t< std::is_constructible::value && - !replaceable_detail::is_constructible_from_replaceable_v && - !replaceable_detail::is_convertible_from_replaceable_v && + !replaceable_detail::is_constructible_from_replaceable< + T>::value && + !replaceable_detail::is_convertible_from_replaceable::value && std::is_convertible::value, int> = 0> /* implicit */ Replaceable(const Replaceable& other) @@ -541,8 +532,9 @@ class alignas(T) Replaceable class U, std::enable_if_t< std::is_constructible::value && - !replaceable_detail::is_constructible_from_replaceable_v && - !replaceable_detail::is_convertible_from_replaceable_v && + !replaceable_detail::is_constructible_from_replaceable< + T>::value && + !replaceable_detail::is_convertible_from_replaceable::value && !std::is_convertible::value, int> = 0> explicit Replaceable(const Replaceable& other) @@ -557,8 +549,9 @@ class alignas(T) Replaceable class U, std::enable_if_t< std::is_constructible::value && - !replaceable_detail::is_constructible_from_replaceable_v && - !replaceable_detail::is_convertible_from_replaceable_v && + !replaceable_detail::is_constructible_from_replaceable< + T>::value && + !replaceable_detail::is_convertible_from_replaceable::value && std::is_convertible::value, int> = 0> /* implicit */ Replaceable(Replaceable&& other) @@ -573,8 +566,9 @@ class alignas(T) Replaceable class U, std::enable_if_t< std::is_constructible::value && - !replaceable_detail::is_constructible_from_replaceable_v && - !replaceable_detail::is_convertible_from_replaceable_v && + !replaceable_detail::is_constructible_from_replaceable< + T>::value && + !replaceable_detail::is_convertible_from_replaceable::value && !std::is_convertible::value, int> = 0> explicit Replaceable(Replaceable&& other) @@ -629,7 +623,7 @@ class alignas(T) Replaceable return launder(reinterpret_cast(storage_)); } - constexpr T* operator->() { + FOLLY_CPP14_CONSTEXPR T* operator->() { return launder(reinterpret_cast(storage_)); } @@ -637,11 +631,11 @@ class alignas(T) Replaceable return *launder(reinterpret_cast(storage_)); } - constexpr T& operator*() & { + FOLLY_CPP14_CONSTEXPR T& operator*() & { return *launder(reinterpret_cast(storage_)); } - constexpr T&& operator*() && { + FOLLY_CPP14_CONSTEXPR T&& operator*() && { return std::move(*launder(reinterpret_cast(storage_))); }