#include <type_traits>
#include <utility>
+#include <folly/Portability.h>
#include <folly/Range.h>
#include <folly/Utility.h>
#include <folly/portability/BitsFunctexcept.h>
#include <folly/portability/Constexpr.h>
-// Define FOLLY_USE_CPP14_CONSTEXPR to be true if the compiler's C++14
-// constexpr support is "good enough".
-#ifndef FOLLY_USE_CPP14_CONSTEXPR
-#if defined(__clang__)
-#define FOLLY_USE_CPP14_CONSTEXPR __cplusplus >= 201300L
-#elif defined(__GNUC__)
-#define FOLLY_USE_CPP14_CONSTEXPR __cplusplus >= 201304L
-#else
-#define FOLLY_USE_CPP14_CONSTEXPR 0 // MSVC?
-#endif
-#endif
-
-#if FOLLY_USE_CPP14_CONSTEXPR
-#define FOLLY_CPP14_CONSTEXPR constexpr
-#else
-#define FOLLY_CPP14_CONSTEXPR inline
-#endif
-
namespace folly {
template <class Char, std::size_t N>
constexpr auto kMscVer = 0;
#endif
}
+
+// Define FOLLY_USE_CPP14_CONSTEXPR to be true if the compiler's C++14
+// constexpr support is "good enough".
+#ifndef FOLLY_USE_CPP14_CONSTEXPR
+#if defined(__clang__)
+#define FOLLY_USE_CPP14_CONSTEXPR __cplusplus >= 201300L
+#elif defined(__GNUC__)
+#define FOLLY_USE_CPP14_CONSTEXPR __cplusplus >= 201304L
+#else
+#define FOLLY_USE_CPP14_CONSTEXPR 0 // MSVC?
+#endif
+#endif
+
+#if FOLLY_USE_CPP14_CONSTEXPR
+#define FOLLY_CPP14_CONSTEXPR constexpr
+#else
+#define FOLLY_CPP14_CONSTEXPR inline
+#endif
#include <utility>
#include <folly/Launder.h>
+#include <folly/Portability.h>
#include <folly/Traits.h>
#include <folly/Utility.h>
template <
class... Args,
std::enable_if_t<std::is_constructible<T, Args&&...>::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<T, Args&&...>::value)
// clang-format on
std::enable_if_t<
std::is_constructible<T, std::initializer_list<U>, Args&&...>::value,
int> = 0>
- constexpr explicit Replaceable(
+ FOLLY_CPP14_CONSTEXPR explicit Replaceable(
in_place_t,
std::initializer_list<U> il,
Args&&... args)
!std::is_same<Replaceable<T>, std::decay_t<U>>::value &&
std::is_convertible<U&&, T>::value,
int> = 0>
- constexpr /* implicit */ Replaceable(U&& other)
+ FOLLY_CPP14_CONSTEXPR /* implicit */ Replaceable(U&& other)
// clang-format off
noexcept(std::is_nothrow_constructible<T, U&&>::value)
// clang-format on
!std::is_same<Replaceable<T>, std::decay_t<U>>::value &&
!std::is_convertible<U&&, T>::value,
int> = 0>
- explicit constexpr Replaceable(U&& other)
+ FOLLY_CPP14_CONSTEXPR explicit Replaceable(U&& other)
// clang-format off
noexcept(std::is_nothrow_constructible<T, U&&>::value)
// clang-format on
return launder(reinterpret_cast<T const*>(storage_));
}
- constexpr T* operator->() {
+ FOLLY_CPP14_CONSTEXPR T* operator->() {
return launder(reinterpret_cast<T*>(storage_));
}
return *launder(reinterpret_cast<T const*>(storage_));
}
- constexpr T& operator*() & {
+ FOLLY_CPP14_CONSTEXPR T& operator*() & {
return *launder(reinterpret_cast<T*>(storage_));
}
- constexpr T&& operator*() && {
+ FOLLY_CPP14_CONSTEXPR T&& operator*() && {
return std::move(*launder(reinterpret_cast<T*>(storage_)));
}
std::is_nothrow_copy_constructible<TypeParam>::value,
std::is_nothrow_copy_assignable<Replaceable<TypeParam>>::value);
}
+TYPED_TEST(ReplaceableStaticAttributeTest, replaceable) {
+ EXPECT_FALSE(is_replaceable<TypeParam>::value);
+ EXPECT_TRUE(is_replaceable<Replaceable<TypeParam>>::value);
+}
TYPED_TEST(ReplaceableStaticAttributePairTest, copy_construct) {
using T = typename TypeParam::first_type;