proxygen
folly::detail::EndianInt< T > Struct Template Reference

#include <Bits.h>

Static Public Member Functions

static T swap (T x)
 
static T big (T x)
 
static T little (T x)
 

Detailed Description

template<class T>
struct folly::detail::EndianInt< T >

Definition at line 199 of file Bits.h.

Member Function Documentation

template<class T >
static T folly::detail::EndianInt< T >::big ( T  x)
inlinestatic

Definition at line 215 of file Bits.h.

References folly::kIsLittleEndian, folly::detail::EndianInt< T >::swap(), and x.

Referenced by folly::Endian::big().

215  {
216  return kIsLittleEndian ? EndianInt::swap(x) : x;
217  }
Definition: InvokeTest.cpp:58
constexpr auto kIsLittleEndian
Definition: Portability.h:278
static T swap(T x)
Definition: Bits.h:204
template<class T >
static T folly::detail::EndianInt< T >::little ( T  x)
inlinestatic

Definition at line 218 of file Bits.h.

References folly::kIsBigEndian, folly::detail::EndianInt< T >::swap(), and x.

Referenced by folly::Endian::little().

218  {
219  return kIsBigEndian ? EndianInt::swap(x) : x;
220  }
Definition: InvokeTest.cpp:58
static T swap(T x)
Definition: Bits.h:204
constexpr auto kIsBigEndian
Definition: Portability.h:280
template<class T >
static T folly::detail::EndianInt< T >::swap ( T  x)
inlinestatic

Definition at line 204 of file Bits.h.

References b, folly::detail::byteswap_gen(), s, folly::T, and x.

Referenced by folly::detail::EndianInt< T >::big(), folly::detail::EndianInt< T >::little(), and folly::Endian::swap().

204  {
205  // we implement this with memcpy because that is defined behavior in C++
206  // we rely on compilers to optimize away the memcpy calls
207  constexpr auto s = sizeof(T);
208  using B = typename uint_types_by_size<s>::type;
209  B b;
210  std::memcpy(&b, &x, s);
211  b = byteswap_gen(b);
212  std::memcpy(&x, &b, s);
213  return x;
214  }
Definition: InvokeTest.cpp:58
static uint8_t byteswap_gen(uint8_t v)
Definition: Bits.h:185
char b
PskType type
const int x
folly::std T
static set< string > s
#define B(name, bit)
Definition: CpuId.h:178

The documentation for this struct was generated from the following file: