16 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 17 #pragma message "Folly.Poly requires gcc-5 or greater" 28 using namespace folly;
35 std::array<char, sizeof(Poly<ISemiRegular>) + 1>
data_;
39 Big_t() :
data_{}, t_() {
42 explicit Big_t(
T t) :
data_{}, t_(
t) {
45 Big_t(Big_t
const& that) :
data_(that.
data_), t_(that.t_) {
51 Big_t& operator=(Big_t
const&) =
default;
56 return a.value() == b.value();
58 friend bool operator!=(Big_t
const& a, Big_t
const& b) {
61 friend bool operator<(Big_t
const& a, Big_t
const& b) {
62 return a.value() < b.value();
64 static std::ptrdiff_t s_count;
67 std::ptrdiff_t Big_t<T>::s_count = 0;
69 using Big = Big_t<int>;
70 using BigDouble = Big_t<double>;
355 EXPECT_EQ(&poly_cast<int>(p1), &poly_cast<int>(p2));
358 EXPECT_EQ(&poly_cast<int>(p3), &poly_cast<int>(p1));
359 EXPECT_EQ(&poly_cast<int>(p4), &poly_cast<int>(p1));
388 template <
class Base>
391 folly::poly_call<0>(*
this,
i);
401 explicit foo_(
int i) : j_(i) {}
421 template <
class Base>
424 return folly::poly_call<0>(*
this,
i);
434 explicit foo_bar(
int i) : j_(i) {}
440 return folly::to<std::string>(
i);
473 template <
class Base>
476 return folly::poly_call<0>(*
this,
i, j);
485 template <
class Base>
488 return folly::poly_call<0>(*this);
496 struct foo_bar_baz_fizz {
497 foo_bar_baz_fizz() =
default;
498 explicit foo_bar_baz_fizz(
int i) : j_(i) {}
503 return folly::to<std::string>(i + j_);
506 return folly::to<std::string>(i + j);
530 template <
class Base>
533 return folly::poly_call<0>(*this);
536 folly::poly_call<1>(*
this,
i);
546 struct has_property {
547 has_property() =
default;
548 explicit has_property(
int i) : j(i) {}
590 MoveOnly_() =
default;
591 MoveOnly_(MoveOnly_&&) =
default;
592 MoveOnly_(MoveOnly_
const&) =
delete;
593 MoveOnly_& operator=(MoveOnly_&&) =
default;
594 MoveOnly_& operator=(MoveOnly_
const&) =
delete;
606 EXPECT_EQ(&poly_cast<int>(p), &poly_cast<int>(q));
614 EXPECT_EQ(&poly_cast<int>(p), &poly_cast<int>(q));
627 static_assert(std::is_same<decltype(poly_cast<int>(p)),
int&>::
value,
"");
635 template <
class R,
class... As>
636 struct IFunction<R(As...)> {
637 template <
class Base>
639 R operator()(As...
as)
const {
640 return static_cast<R
>(
641 folly::poly_call<0>(*
this, std::forward<As>(
as)...));
657 fun = std::multiplies<int>{};
663 struct IDiamond :
PolyExtends<IRegular, INullablePointer> {};
678 EXPECT_EQ(&poly_cast<int>(p), &poly_cast<int>(eq));
695 EXPECT_EQ(&poly_cast<Big>(p), &poly_cast<Big>(eq));
702 int property()
const {
705 void property(
int) {}
707 struct Struct2 : Struct {
720 int property(Struct
const&) {
723 void property(Struct&,
int) {}
732 int purr(Struct2
const&) {
739 auto m0 = folly::sig<int() const>(&Struct::property);
740 EXPECT_EQ(
static_cast<int (Struct::*)()
const>(&Struct::property), m0);
741 auto m1 = folly::sig<int()>(&Struct::property);
742 EXPECT_EQ(
static_cast<int (Struct::*)()
const>(&Struct::property), m1);
744 auto m2 = folly::sig<int() const>(&Struct2::property);
745 EXPECT_EQ(
static_cast<int (Struct2::*)()
const>(&Struct2::property), m2);
746 auto m3 = folly::sig<int()>(&Struct2::property);
747 EXPECT_EQ(
static_cast<int (Struct2::*)()
const>(&Struct2::property), m3);
749 auto m4 = folly::sig<long()>(&Struct2::meow);
752 auto m5 = folly::sig<int()>(&Struct2::purr);
753 EXPECT_EQ(
static_cast<int (Struct2::*)()
>(&Struct2::purr), m5);
754 auto m6 = folly::sig<int() const>(&Struct2::purr);
755 EXPECT_EQ(
static_cast<int (Struct2::*)()
const>(&Struct2::purr), m6);
758 auto m0 = folly::sig<int(Struct const&)>(&::property);
760 auto m1 = folly::sig<int(Struct&)>(&::property);
763 auto m2 = folly::sig<long(Struct2&)>(&::meow);
766 auto m3 = folly::sig<int(Struct2&)>(&::purr);
767 EXPECT_EQ(
static_cast<int (*)(Struct2&)
>(&::purr), m3);
768 auto m4 = folly::sig<int(Struct2 const&)>(&::purr);
775 template <
class Base>
780 return folly::poly_call<0, IAddable>(
a,
b);
784 static auto plus_(
T const& a,
T const& b) -> decltype(a + b) {
800 auto cc = aref + bref;
811 struct IFrobnicator {
812 template <
class Base>
815 folly::poly_call<0>(*
this,
x);
823 struct my_frobnicator {
832 Frobnicator frob = my_frobnicator{};
std::type_info const & poly_type(detail::PolyRoot< I > const &that) noexcept
#define EXPECT_THROW(statement, expected_exception)
#define FOLLY_POLY_MEMBERS(...)
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
The non test part of the code is expected to have failures gtest_output_test_ cc
—— Concurrent Priority Queue Implementation ——
bool operator!=(const Unexpected< Error > &lhs, const Unexpected< Error > &rhs)
AtomicCounter< T, DeterministicAtomic > Base
bool poly_empty(detail::PolyRoot< I > const &that) noexcept
folly::Singleton< int > bar
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
#define EXPECT_TRUE(condition)
void swap(exception_wrapper &a, exception_wrapper &b) noexcept
constexpr Poly< I > && poly_move(detail::PolyRoot< I > &that) noexcept
bool operator==(const Unexpected< Error > &lhs, const Unexpected< Error > &rhs)
basic_fbstring< E, T, A, S > operator+(const basic_fbstring< E, T, A, S > &lhs, const basic_fbstring< E, T, A, S > &rhs)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
#define EXPECT_FALSE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
decltype(Access::template self_< Node, Tfx >()) PolySelf
std::enable_if< IsLessThanComparable< Value >::value, bool >::type operator<(const Expected< Value, Error > &lhs, const Expected< Value, Error > &rhs)
#define FOLLY_POLY_MEMBER(SIG, MEM)