21 #include <type_traits> 27 using namespace folly;
35 TEST(Traits, has_member_type) {
36 struct membership_no {};
37 struct membership_yes {
143 EXPECT_FALSE((folly::less_than<uint8_t, 0u, uint8_t>(0u)));
144 EXPECT_FALSE((folly::less_than<uint8_t, 0u, uint8_t>(254u)));
145 EXPECT_FALSE((folly::less_than<uint8_t, 255u, uint8_t>(255u)));
146 EXPECT_TRUE((folly::less_than<uint8_t, 255u, uint8_t>(254u)));
148 EXPECT_FALSE((folly::greater_than<uint8_t, 0u, uint8_t>(0u)));
149 EXPECT_TRUE((folly::greater_than<uint8_t, 0u, uint8_t>(254u)));
150 EXPECT_FALSE((folly::greater_than<uint8_t, 255u, uint8_t>(255u)));
151 EXPECT_FALSE((folly::greater_than<uint8_t, 255u, uint8_t>(254u)));
154 #if FOLLY_HAVE_INT128_T 156 TEST(Traits, int128) {
182 #endif // FOLLY_HAVE_INT128_T 184 template <
typename T,
typename...
Args>
191 char vsrc[
sizeof(
T)] = {0};
192 char vdst[
sizeof(
T)] = {0};
193 char vcpy[
sizeof(
T)];
195 T* src =
new (vsrc)
T(std::forward<Args>(args)...);
199 std::memcpy(vcpy, vsrc,
sizeof(
T));
207 #pragma GCC diagnostic push 208 #pragma GCC diagnostic ignored "-Wstrict-aliasing" 209 EXPECT_EQ(deep, *reinterpret_cast<T*>(vcpy));
210 #pragma GCC diagnostic pop 214 EXPECT_EQ(std::memcmp(vcpy, vdst,
sizeof(
T)), 0);
217 TEST(Traits, actuallyRelocatable) {
220 testIsRelocatable<std::string>(
"1");
221 testIsRelocatable<std::string>(
sizeof(
std::string) + 1,
'x');
223 testIsRelocatable<std::vector<char>>(5,
'g');
228 template <
class T,
class =
void>
232 struct has_value_type<T, folly::
void_t<typename T::value_type>>
237 template <
typename T>
239 template <
class...
Args>
264 ::std::is_constructible<::container<std::string>, some_tag,
std::string>::
267 (::std::is_constructible<::container<std::string>, some_tag,
float>::
std::false_type IsRelocatable
typename remove_cvref< T >::type remove_cvref_t
FOLLY_ASSUME_RELOCATABLE(basic_fbstring< T, R, A, S >)
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
std::true_type IsRelocatable
typename traits_detail::type_t_< T, Ts... >::type type_t
bool_constant< true > true_type
constexpr bool is_non_positive(T x)
typename detail::like_< Src >::template apply< remove_cvref_t< Dst >> like_t
type_t< void, Ts... > void_t
#define FOLLY_CREATE_HAS_MEMBER_TYPE_TRAITS(classname, type_name)
static const char *const value
void testIsRelocatable(Args &&...args)
#define EXPECT_TRUE(condition)
typename std::remove_cv< typename std::remove_reference< T >::type >::type type
constexpr bool is_negative(T x)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
bool_constant< false > false_type
#define EXPECT_FALSE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)