proxygen
Traits.h File Reference
#include <functional>
#include <limits>
#include <memory>
#include <type_traits>
#include <folly/Portability.h>

Go to the source code of this file.

Classes

struct  folly::remove_cvref< T >
 
struct  folly::detail::like_< Src >
 
struct  folly::detail::like_< Src const >
 
struct  folly::detail::like_< Src volatile >
 
struct  folly::detail::like_< Src const volatile >
 
struct  folly::detail::like_< Src & >
 
struct  folly::detail::like_< Src && >
 
struct  folly::like< Src, Dst >
 
struct  folly::traits_detail::type_t_< T,... >
 
struct  folly::traits_detail::has_IsRelocatable__folly_traits_impl__< TTheClass_ >
 
struct  folly::traits_detail::IsRelocatable_is_true< T >
 
struct  folly::traits_detail::has_true_IsRelocatable< T >
 
struct  folly::traits_detail::has_IsZeroInitializable__folly_traits_impl__< TTheClass_ >
 
struct  folly::traits_detail::IsZeroInitializable_is_true< T >
 
struct  folly::traits_detail::has_true_IsZeroInitializable< T >
 
struct  folly::Ignore
 
struct  folly::traits_detail_IsEqualityComparable::IsEqualityComparable< T, U >
 
struct  folly::traits_detail_IsLessThanComparable::IsLessThanComparable< T, U >
 
struct  folly::traits_detail_IsNothrowSwappable::IsNothrowSwappable< T >
 
struct  folly::IsRelocatable< T >
 
struct  folly::IsZeroInitializable< T >
 
struct  folly::Conjunction<... >
 
struct  folly::Conjunction< T >
 
struct  folly::Conjunction< T, TList... >
 
struct  folly::Disjunction<... >
 
struct  folly::Disjunction< T >
 
struct  folly::Disjunction< T, TList... >
 
struct  folly::Negation< T >
 
struct  folly::Bools< Bs >
 
struct  folly::StrictConjunction< Ts >
 
struct  folly::StrictDisjunction< Ts >
 
struct  pair< T, U >
 
class  basic_string< T, R, A >
 
class  vector< T, A >
 
class  deque< T, A >
 
class  set< T, C, A >
 
class  map< K, V, C, A >
 
class  shared_ptr< T >
 
struct  folly::IsRelocatable< std::pair< T, U > >
 
struct  folly::detail::is_negative_impl< T, bool >
 
struct  folly::detail::is_negative_impl< T, false >
 
struct  folly::IsRelocatable< std::basic_string< T1, T2, T3 > >
 
struct  folly::IsRelocatable< std::vector< T1, T2 > >
 
struct  folly::IsRelocatable< std::deque< T1, T2 > >
 
struct  folly::IsRelocatable< std::unique_ptr< T1, T2 > >
 
struct  folly::IsRelocatable< std::shared_ptr< T1 > >
 
struct  folly::IsRelocatable< std::function< T1 > >
 

Namespaces

 folly
 —— Concurrent Priority Queue Implementation ——
 
 folly::detail
 
 folly::traits_detail
 
 folly::traits_detail_IsEqualityComparable
 
 folly::traits_detail_IsLessThanComparable
 
 folly::traits_detail_IsNothrowSwappable
 

Macros

#define FOLLY_CREATE_HAS_MEMBER_TYPE_TRAITS(classname, type_name)
 
#define FOLLY_CREATE_HAS_MEMBER_FN_TRAITS_IMPL(classname, func_name, cv_qual)
 
#define FOLLY_CREATE_HAS_MEMBER_FN_TRAITS(classname, func_name)
 
#define FOLLY_HAS_TRUE_XXX(name)
 
#define FOLLY_ASSUME_RELOCATABLE(...)   struct IsRelocatable<__VA_ARGS__> : std::true_type {}
 
#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE(...)
 
#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(...)
 
#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(...)
 
#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE_3(...)
 
#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE_4(...)
 

Typedefs

template<bool B>
using folly::bool_constant = std::integral_constant< bool, B >
 
template<std::size_t I>
using folly::index_constant = std::integral_constant< std::size_t, I >
 
template<typename T >
using folly::_t = typename T::type
 
template<typename T >
using folly::remove_cvref_t = typename remove_cvref< T >::type
 
template<typename Src , typename Dst >
using folly::like_t = typename detail::like_< Src >::template apply< remove_cvref_t< Dst >>
 
template<class T , class... Ts>
using folly::type_t = typename traits_detail::type_t_< T, Ts... >::type
 
template<class... Ts>
using folly::void_t = type_t< void, Ts... >
 
template<class T >
using folly::is_trivially_copyable = std::is_trivially_copyable< T >
 
template<typename TTheClass_ >
using folly::traits_detail::has_IsRelocatable = typename std::conditional< has_IsRelocatable__folly_traits_impl__< TTheClass_ >::template test< TTheClass_ >(nullptr), std::true_type, std::false_type >::type
 
template<typename TTheClass_ >
using folly::traits_detail::has_IsZeroInitializable = typename std::conditional< has_IsZeroInitializable__folly_traits_impl__< TTheClass_ >::template test< TTheClass_ >(nullptr), std::true_type, std::false_type >::type
 
template<class... >
using folly::Ignored = Ignore
 
template<typename T , typename... Ts>
using folly::IsOneOf = StrictDisjunction< std::is_same< T, Ts >... >
 

Functions

Ignore folly::traits_detail_IsEqualityComparable::operator== (Ignore, Ignore)
 
Ignore folly::traits_detail_IsLessThanComparable::operator< (Ignore, Ignore)
 
FOLLY_PUSH_WARNING folly::detail::FOLLY_MSVC_DISABLE_WARNING (4388) FOLLY_MSVC_DISABLE_WARNING(4804) template< typename RHS
 
FOLLY_PUSH_WARNING RHS LHS bool folly::detail::less_than_impl (LHS const lhs)
 
template<typename RHS , RHS rhs, typename LHS >
bool folly::detail::greater_than_impl (LHS const lhs)
 
template<typename T >
constexpr bool folly::is_negative (T x)
 
template<typename T >
constexpr bool folly::is_non_positive (T x)
 
template<typename T >
constexpr bool folly::is_positive (T x)
 
template<typename T >
constexpr bool folly::is_non_negative (T x)
 
template<typename RHS , RHS rhs, typename LHS >
bool folly::less_than (LHS const lhs)
 
template<typename RHS , RHS rhs, typename LHS >
bool folly::greater_than (LHS const lhs)
 

Variables

FOLLY_PUSH_WARNING RHS folly::detail::rhs
 

Macro Definition Documentation

#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE (   ...)
Value:
namespace folly { \
template <> \
}
FOLLY_ASSUME_RELOCATABLE(basic_fbstring< T, R, A, S >)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29

The FOLLY_ASSUME_FBVECTOR_COMPATIBLE* macros below encode the assumption that the type is relocatable per IsRelocatable above. Many types can be assumed to satisfy this condition, but it is the responsibility of the user to state that assumption. User-defined classes will not be optimized for use with fbvector (see FBVector.h) unless they state that assumption.

Use FOLLY_ASSUME_FBVECTOR_COMPATIBLE with regular types like this:

FOLLY_ASSUME_FBVECTOR_COMPATIBLE(MyType)

The versions FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1, _2, _3, and _4 allow using the macro for describing templatized classes with 1, 2, 3, and 4 template parameters respectively. For template classes just use the macro with the appropriate number and pass the name of the template to it. Example:

template <class T1, class T2> class MyType { ... }; ... // Make sure you're at global scope FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2(MyType)

Definition at line 537 of file Traits.h.

#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1 (   ...)
Value:
namespace folly { \
template <class T1> \
FOLLY_ASSUME_RELOCATABLE(__VA_ARGS__<T1>); \
}
FOLLY_ASSUME_RELOCATABLE(basic_fbstring< T, R, A, S >)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29

Definition at line 543 of file Traits.h.

Referenced by folly::literals::string_piece_literals::operator""_sp().

#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE_2 (   ...)
Value:
namespace folly { \
template <class T1, class T2> \
FOLLY_ASSUME_RELOCATABLE(__VA_ARGS__<T1, T2>); \
}
FOLLY_ASSUME_RELOCATABLE(basic_fbstring< T, R, A, S >)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29

Definition at line 549 of file Traits.h.

#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE_3 (   ...)
Value:
namespace folly { \
template <class T1, class T2, class T3> \
FOLLY_ASSUME_RELOCATABLE(__VA_ARGS__<T1, T2, T3>); \
}
FOLLY_ASSUME_RELOCATABLE(basic_fbstring< T, R, A, S >)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29

Definition at line 555 of file Traits.h.

#define FOLLY_ASSUME_FBVECTOR_COMPATIBLE_4 (   ...)
Value:
namespace folly { \
template <class T1, class T2, class T3, class T4> \
FOLLY_ASSUME_RELOCATABLE(__VA_ARGS__<T1, T2, T3, T4>); \
}
FOLLY_ASSUME_RELOCATABLE(basic_fbstring< T, R, A, S >)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29

Definition at line 561 of file Traits.h.

#define FOLLY_ASSUME_RELOCATABLE (   ...)    struct IsRelocatable<__VA_ARGS__> : std::true_type {}

Use this macro ONLY inside namespace folly. When using it with a regular type, use it like this:

// Make sure you're at namespace folly scope template <> FOLLY_ASSUME_RELOCATABLE(MyType)

When using it with a template type, use it like this:

// Make sure you're at namespace folly scope template <class T1, class T2> FOLLY_ASSUME_RELOCATABLE(MyType<T1, T2>)

Definition at line 509 of file Traits.h.

#define FOLLY_CREATE_HAS_MEMBER_FN_TRAITS (   classname,
  func_name 
)
Value:
template <typename, typename> \
struct classname##__folly_traits_impl__; \
FOLLY_CREATE_HAS_MEMBER_FN_TRAITS_IMPL(classname, func_name, const); \
classname, func_name, /* nolint */ volatile); \
classname, func_name, /* nolint */ volatile const); \
template <typename TTheClass_, typename TTheSignature_> \
using classname = \
decltype(classname##__folly_traits_impl__<TTheClass_, TTheSignature_>:: \
template test<TTheClass_>(nullptr))
#define FOLLY_CREATE_HAS_MEMBER_FN_TRAITS_IMPL(classname, func_name, cv_qual)
Definition: Traits.h:58

Definition at line 121 of file Traits.h.

#define FOLLY_CREATE_HAS_MEMBER_FN_TRAITS_IMPL (   classname,
  func_name,
  cv_qual 
)
Value:
template <typename TTheClass_, typename RTheReturn_, typename... TTheArgs_> \
struct classname##__folly_traits_impl__< \
TTheClass_, \
RTheReturn_(TTheArgs_...) cv_qual> { \
template < \
typename UTheClass_, \
RTheReturn_ (UTheClass_::*)(TTheArgs_...) cv_qual> \
struct sfinae {}; \
template <typename UTheClass_> \
static std::true_type test(sfinae<UTheClass_, &UTheClass_::func_name>*); \
template <typename> \
static std::false_type test(...); \
}
static uint64_t test(std::string name, bool fc_, bool dedicated_, bool tc_, bool syncops_, uint64_t base)
bool_constant< true > true_type
Definition: gtest-port.h:2210
bool_constant< false > false_type
Definition: gtest-port.h:2209

Definition at line 58 of file Traits.h.

#define FOLLY_CREATE_HAS_MEMBER_TYPE_TRAITS (   classname,
  type_name 
)
Value:
template <typename TTheClass_> \
struct classname##__folly_traits_impl__ { \
template <typename UTheClass_> \
static constexpr bool test(typename UTheClass_::type_name*) { \
return true; \
} \
template <typename> \
static constexpr bool test(...) { \
return false; \
} \
}; \
template <typename TTheClass_> \
using classname = typename std::conditional< \
classname##__folly_traits_impl__<TTheClass_>::template test<TTheClass_>( \
PskType type
static uint64_t test(std::string name, bool fc_, bool dedicated_, bool tc_, bool syncops_, uint64_t base)
#define nullptr
Definition: http_parser.c:41
bool_constant< true > true_type
Definition: gtest-port.h:2210
bool_constant< false > false_type
Definition: gtest-port.h:2209

Definition at line 39 of file Traits.h.

#define FOLLY_HAS_TRUE_XXX (   name)
Value:
template <class T> \
struct name##_is_true : std::is_same<typename T::name, std::true_type> {}; \
template <class T> \
struct has_true_##name : std::conditional< \
name##_is_true<T>, \
PskType type
const char * name
Definition: http_parser.c:437
#define FOLLY_CREATE_HAS_MEMBER_TYPE_TRAITS(classname, type_name)
Definition: Traits.h:39
static const char *const value
Definition: Conv.cpp:50
bool_constant< false > false_type
Definition: gtest-port.h:2209

Definition at line 360 of file Traits.h.