proxygen
Function.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /*
17  * @author Eric Niebler (eniebler@fb.com), Sven Over (over@fb.com)
18  * Acknowledgements: Giuseppe Ottaviano (ott@fb.com)
19  */
20 
218 #pragma once
219 
220 #include <functional>
221 #include <memory>
222 #include <new>
223 #include <type_traits>
224 #include <utility>
225 
226 #include <folly/CppAttributes.h>
227 #include <folly/Portability.h>
228 #include <folly/Traits.h>
229 #include <folly/functional/Invoke.h>
230 #include <folly/lang/Exception.h>
231 
232 namespace folly {
233 
234 template <typename FunctionType>
235 class Function;
236 
237 template <typename ReturnType, typename... Args>
238 Function<ReturnType(Args...) const> constCastFunction(
239  Function<ReturnType(Args...)>&&) noexcept;
240 
241 #if FOLLY_HAVE_NOEXCEPT_FUNCTION_TYPE
242 template <typename ReturnType, typename... Args>
243 Function<ReturnType(Args...) const noexcept> constCastFunction(
244  Function<ReturnType(Args...) noexcept>&&) noexcept;
245 #endif
246 
247 namespace detail {
248 namespace function {
249 
250 enum class Op { MOVE, NUKE, HEAP };
251 
252 union Data {
253  Data() {}
254  void* big;
256 };
257 
258 template <typename Fun, typename = Fun*>
259 using IsSmall = Conjunction<
261  std::is_nothrow_move_constructible<Fun>>;
264 
265 template <typename T>
267 template <typename T>
269 
270 template <typename T>
271 using EnableIfNotFunction =
273 
274 struct CoerceTag {};
275 
276 template <typename T>
277 bool isNullPtrFn(T* p) {
278  return p == nullptr;
279 }
280 template <typename T>
282  return {};
283 }
284 
285 template <typename F, typename... Args>
286 using CallableResult = decltype(std::declval<F>()(std::declval<Args>()...));
287 
288 template <
289  typename From,
290  typename To,
291  typename = typename std::enable_if<
293 using SafeResultOf = decltype(static_cast<To>(std::declval<From>()));
294 
295 template <typename FunctionType>
297 
298 template <typename ReturnType, typename... Args>
299 struct FunctionTraits<ReturnType(Args...)> {
300  using Call = ReturnType (*)(Data&, Args&&...);
302  using ConstSignature = ReturnType(Args...) const;
303  using NonConstSignature = ReturnType(Args...);
305 
306  template <typename F>
307  using ResultOf =
309 
310  template <typename Fun>
311  static ReturnType callSmall(Data& p, Args&&... args) {
312  return static_cast<ReturnType>((*static_cast<Fun*>(
313  static_cast<void*>(&p.tiny)))(static_cast<Args&&>(args)...));
314  }
315 
316  template <typename Fun>
317  static ReturnType callBig(Data& p, Args&&... args) {
318  return static_cast<ReturnType>(
319  (*static_cast<Fun*>(p.big))(static_cast<Args&&>(args)...));
320  }
321 
322  static ReturnType uninitCall(Data&, Args&&...) {
323  throw std::bad_function_call();
324  }
325 
326  ReturnType operator()(Args... args) {
327  auto& fn = *static_cast<Function<NonConstSignature>*>(this);
328  return fn.call_(fn.data_, static_cast<Args&&>(args)...);
329  }
330 
331  class SharedProxy {
332  std::shared_ptr<Function<NonConstSignature>> sp_;
333 
334  public:
336  : sp_(std::make_shared<Function<NonConstSignature>>(std::move(func))) {}
337  ReturnType operator()(Args&&... args) const {
338  return (*sp_)(static_cast<Args&&>(args)...);
339  }
340  };
341 };
342 
343 template <typename ReturnType, typename... Args>
344 struct FunctionTraits<ReturnType(Args...) const> {
345  using Call = ReturnType (*)(Data&, Args&&...);
347  using ConstSignature = ReturnType(Args...) const;
348  using NonConstSignature = ReturnType(Args...);
350 
351  template <typename F>
352  using ResultOf = SafeResultOf<
354  ReturnType>;
355 
356  template <typename Fun>
357  static ReturnType callSmall(Data& p, Args&&... args) {
358  return static_cast<ReturnType>((*static_cast<const Fun*>(
359  static_cast<void*>(&p.tiny)))(static_cast<Args&&>(args)...));
360  }
361 
362  template <typename Fun>
363  static ReturnType callBig(Data& p, Args&&... args) {
364  return static_cast<ReturnType>(
365  (*static_cast<const Fun*>(p.big))(static_cast<Args&&>(args)...));
366  }
367 
368  static ReturnType uninitCall(Data&, Args&&...) {
369  throw std::bad_function_call();
370  }
371 
372  ReturnType operator()(Args... args) const {
373  auto& fn = *static_cast<const Function<ConstSignature>*>(this);
374  return fn.call_(fn.data_, static_cast<Args&&>(args)...);
375  }
376 
377  class SharedProxy {
378  std::shared_ptr<Function<ConstSignature>> sp_;
379 
380  public:
382  : sp_(std::make_shared<Function<ConstSignature>>(std::move(func))) {}
383  ReturnType operator()(Args&&... args) const {
384  return (*sp_)(static_cast<Args&&>(args)...);
385  }
386  };
387 };
388 
389 #if FOLLY_HAVE_NOEXCEPT_FUNCTION_TYPE
390 template <typename ReturnType, typename... Args>
391 struct FunctionTraits<ReturnType(Args...) noexcept> {
392  using Call = ReturnType (*)(Data&, Args&&...) noexcept;
393  using IsConst = std::false_type;
394  using ConstSignature = ReturnType(Args...) const noexcept;
395  using NonConstSignature = ReturnType(Args...) noexcept;
397 
398  template <typename F>
399  using ResultOf =
400  SafeResultOf<CallableResult<_t<std::decay<F>>&, Args...>, ReturnType>;
401 
402  template <typename Fun>
403  static ReturnType callSmall(Data& p, Args&&... args) noexcept {
404  return static_cast<ReturnType>((*static_cast<Fun*>(
405  static_cast<void*>(&p.tiny)))(static_cast<Args&&>(args)...));
406  }
407 
408  template <typename Fun>
409  static ReturnType callBig(Data& p, Args&&... args) noexcept {
410  return static_cast<ReturnType>(
411  (*static_cast<Fun*>(p.big))(static_cast<Args&&>(args)...));
412  }
413 
414  static ReturnType uninitCall(Data&, Args&&...) noexcept {
415  terminate_with<std::bad_function_call>();
416  }
417 
418  ReturnType operator()(Args... args) noexcept {
419  auto& fn = *static_cast<Function<NonConstSignature>*>(this);
420  return fn.call_(fn.data_, static_cast<Args&&>(args)...);
421  }
422 
423  class SharedProxy {
424  std::shared_ptr<Function<NonConstSignature>> sp_;
425 
426  public:
427  explicit SharedProxy(Function<NonConstSignature>&& func)
428  : sp_(std::make_shared<Function<NonConstSignature>>(std::move(func))) {}
429  ReturnType operator()(Args&&... args) const {
430  return (*sp_)(static_cast<Args&&>(args)...);
431  }
432  };
433 };
434 
435 template <typename ReturnType, typename... Args>
436 struct FunctionTraits<ReturnType(Args...) const noexcept> {
437  using Call = ReturnType (*)(Data&, Args&&...) noexcept;
438  using IsConst = std::true_type;
439  using ConstSignature = ReturnType(Args...) const noexcept;
440  using NonConstSignature = ReturnType(Args...) noexcept;
442 
443  template <typename F>
444  using ResultOf = SafeResultOf<
446  ReturnType>;
447 
448  template <typename Fun>
449  static ReturnType callSmall(Data& p, Args&&... args) noexcept {
450  return static_cast<ReturnType>((*static_cast<const Fun*>(
451  static_cast<void*>(&p.tiny)))(static_cast<Args&&>(args)...));
452  }
453 
454  template <typename Fun>
455  static ReturnType callBig(Data& p, Args&&... args) noexcept {
456  return static_cast<ReturnType>(
457  (*static_cast<const Fun*>(p.big))(static_cast<Args&&>(args)...));
458  }
459 
460  static ReturnType uninitCall(Data&, Args&&...) noexcept {
461  throw std::bad_function_call();
462  }
463 
464  ReturnType operator()(Args... args) const noexcept {
465  auto& fn = *static_cast<const Function<ConstSignature>*>(this);
466  return fn.call_(fn.data_, static_cast<Args&&>(args)...);
467  }
468 
469  class SharedProxy {
470  std::shared_ptr<Function<ConstSignature>> sp_;
471 
472  public:
473  explicit SharedProxy(Function<ConstSignature>&& func)
474  : sp_(std::make_shared<Function<ConstSignature>>(std::move(func))) {}
475  ReturnType operator()(Args&&... args) const {
476  return (*sp_)(static_cast<Args&&>(args)...);
477  }
478  };
479 };
480 #endif
481 
482 template <typename Fun>
483 bool execSmall(Op o, Data* src, Data* dst) {
484  switch (o) {
485  case Op::MOVE:
486  ::new (static_cast<void*>(&dst->tiny))
487  Fun(std::move(*static_cast<Fun*>(static_cast<void*>(&src->tiny))));
489  case Op::NUKE:
490  static_cast<Fun*>(static_cast<void*>(&src->tiny))->~Fun();
491  break;
492  case Op::HEAP:
493  break;
494  }
495  return false;
496 }
497 
498 template <typename Fun>
499 bool execBig(Op o, Data* src, Data* dst) {
500  switch (o) {
501  case Op::MOVE:
502  dst->big = src->big;
503  src->big = nullptr;
504  break;
505  case Op::NUKE:
506  delete static_cast<Fun*>(src->big);
507  break;
508  case Op::HEAP:
509  break;
510  }
511  return true;
512 }
513 
514 } // namespace function
515 } // namespace detail
516 
517 template <typename FunctionType>
518 class Function final : private detail::function::FunctionTraits<FunctionType> {
519  // These utility types are defined outside of the template to reduce
520  // the number of instantiations, and then imported in the class
521  // namespace for convenience.
527 
529  using Call = typename Traits::Call;
530  using Exec = bool (*)(Op, Data*, Data*);
531 
532  template <typename Fun>
534 
535  // The `data_` member is mutable to allow `constCastFunction` to work without
536  // invoking undefined behavior. Const-correctness is only violated when
537  // `FunctionType` is a const function type (e.g., `int() const`) and `*this`
538  // is the result of calling `constCastFunction`.
539  mutable Data data_{};
540  Call call_{&Traits::uninitCall};
541  Exec exec_{nullptr};
542 
543  bool exec(Op o, Data* src, Data* dst) const {
544  return exec_ && exec_(o, src, dst);
545  }
546 
547  friend Traits;
548  friend Function<typename Traits::ConstSignature> folly::constCastFunction<>(
550  friend class Function<typename Traits::OtherSignature>;
551 
552  template <typename Fun>
553  Function(Fun&& fun, SmallTag) noexcept {
554  using FunT = typename std::decay<Fun>::type;
556  ::new (static_cast<void*>(&data_.tiny)) FunT(static_cast<Fun&&>(fun));
557  call_ = &Traits::template callSmall<FunT>;
558  exec_ = &detail::function::execSmall<FunT>;
559  }
560  }
561 
562  template <typename Fun>
563  Function(Fun&& fun, HeapTag) {
564  using FunT = typename std::decay<Fun>::type;
565  data_.big = new FunT(static_cast<Fun&&>(fun));
566  call_ = &Traits::template callBig<FunT>;
567  exec_ = &detail::function::execBig<FunT>;
568  }
569 
570  template <typename Signature>
572  : Function(static_cast<Function<Signature>&&>(that), HeapTag{}) {}
573 
575  : call_(that.call_), exec_(that.exec_) {
576  that.call_ = &Traits::uninitCall;
577  that.exec_ = nullptr;
578  exec(Op::MOVE, &that.data_, &data_);
579  }
580 
581  public:
585  Function() = default;
586 
587  // not copyable
588  Function(const Function&) = delete;
589 
590 #if __OBJC__
591  // Make sure Objective C blocks are copied
592  template <class ReturnType, class... Args>
593  /*implicit*/ Function(ReturnType (^objCBlock)(Args... args))
594  : Function([blockCopy = (ReturnType(^)(Args...))[objCBlock copy]](
595  Args... args) { return blockCopy(args...); }){};
596 #endif
597 
601  Function(Function&& that) noexcept : call_(that.call_), exec_(that.exec_) {
602  // that must be uninitialized before exec() call in the case of self move
603  that.call_ = &Traits::uninitCall;
604  that.exec_ = nullptr;
605  exec(Op::MOVE, &that.data_, &data_);
606  }
607 
611  /* implicit */ Function(std::nullptr_t) noexcept {}
612 
633  template <
634  typename Fun,
636  typename = typename Traits::template ResultOf<Fun>>
637  /* implicit */ Function(Fun fun) noexcept(
638  IsSmall<Fun>::value&& noexcept(Fun(std::declval<Fun>())))
639  : Function(std::move(fun), IsSmall<Fun>{}) {}
640 
650  template <
651  typename Signature,
652  typename = typename Traits::template ResultOf<Function<Signature>>>
653  Function(Function<Signature>&& that) noexcept(
654  noexcept(Function(std::move(that), CoerceTag{})))
655  : Function(std::move(that), CoerceTag{}) {}
656 
661  template <
662  typename Member,
663  typename Class,
664  // Prevent this overload from being selected when `ptr` is not a
665  // compatible member function pointer.
666  typename = decltype(Function(std::mem_fn((Member Class::*)0)))>
667  /* implicit */ Function(Member Class::*ptr) noexcept {
668  if (ptr) {
669  *this = std::mem_fn(ptr);
670  }
671  }
672 
674  exec(Op::NUKE, &data_, nullptr);
675  }
676 
677  Function& operator=(const Function&) = delete;
678 
679 #if __OBJC__
680  // Make sure Objective C blocks are copied
681  template <class ReturnType, class... Args>
682  /* implicit */ Function& operator=(ReturnType (^objCBlock)(Args... args)) {
683  (*this) = [blockCopy = (ReturnType(^)(Args...))[objCBlock copy]](
684  Args... args) { return blockCopy(args...); };
685  return *this;
686  }
687 #endif
688 
695  Function& operator=(Function&& that) noexcept {
696  // Q: Why is it safe to destroy and reconstruct this object in place?
697  // A: Two reasons: First, `Function` is a final class, so in doing this
698  // we aren't slicing off any derived parts. And second, the move
699  // operation is guaranteed not to throw so we always leave the object
700  // in a valid state.
701  // In the case of self-move (this == &that), this leaves the object in
702  // a default-constructed state. First the object is destroyed, then we
703  // pass the destroyed object to the move constructor. The first thing the
704  // move constructor does is default-construct the object. That object is
705  // "moved" into itself, which is a no-op for a default-constructed Function.
706  this->~Function();
707  ::new (this) Function(std::move(that));
708  return *this;
709  }
710 
719  template <typename Fun, typename = decltype(Function(std::declval<Fun>()))>
720  Function& operator=(Fun fun) noexcept(
721  noexcept(/* implicit */ Function(std::declval<Fun>()))) {
722  // Doing this in place is more efficient when we can do so safely.
723  if (noexcept(/* implicit */ Function(std::declval<Fun>()))) {
724  // Q: Why is is safe to destroy and reconstruct this object in place?
725  // A: See the explanation in the move assignment operator.
726  this->~Function();
727  ::new (this) Function(std::move(fun));
728  } else {
729  // Construct a temporary and (nothrow) swap.
730  Function(std::move(fun)).swap(*this);
731  }
732  return *this;
733  }
734 
738  template <
739  typename Signature,
740  typename = typename Traits::template ResultOf<Function<Signature>>>
741  Function& operator=(Function<Signature>&& that) noexcept(
742  noexcept(Function(std::move(that)))) {
743  return (*this = Function(std::move(that)));
744  }
745 
749  Function& operator=(std::nullptr_t) noexcept {
750  return (*this = Function());
751  }
752 
757  template <typename Member, typename Class>
758  auto operator=(Member Class::*ptr) noexcept
759  // Prevent this overload from being selected when `ptr` is not a
760  // compatible member function pointer.
761  -> decltype(operator=(std::mem_fn(ptr))) {
762  return ptr ? (*this = std::mem_fn(ptr)) : (*this = Function());
763  }
764 
768  using Traits::operator();
769 
773  void swap(Function& that) noexcept {
774  std::swap(*this, that);
775  }
776 
781  explicit operator bool() const noexcept {
782  return exec_ != nullptr;
783  }
784 
791  bool hasAllocatedMemory() const noexcept {
792  return exec(Op::HEAP, nullptr, nullptr);
793  }
794 
795  using typename Traits::SharedProxy;
796 
801  SharedProxy asSharedProxy() && {
802  return SharedProxy{std::move(*this)};
803  }
804 
810  std::function<typename Traits::NonConstSignature> asStdFunction() && {
811  return std::move(*this).asSharedProxy();
812  }
813 };
814 
815 template <typename FunctionType>
817  lhs.swap(rhs);
818 }
819 
820 template <typename FunctionType>
821 bool operator==(const Function<FunctionType>& fn, std::nullptr_t) {
822  return !fn;
823 }
824 
825 template <typename FunctionType>
826 bool operator==(std::nullptr_t, const Function<FunctionType>& fn) {
827  return !fn;
828 }
829 
830 template <typename FunctionType>
831 bool operator!=(const Function<FunctionType>& fn, std::nullptr_t) {
832  return !(fn == nullptr);
833 }
834 
835 template <typename FunctionType>
836 bool operator!=(std::nullptr_t, const Function<FunctionType>& fn) {
837  return !(nullptr == fn);
838 }
839 
844 template <typename ReturnType, typename... Args>
845 Function<ReturnType(Args...) const> constCastFunction(
846  Function<ReturnType(Args...)>&& that) noexcept {
847  return Function<ReturnType(Args...) const>{std::move(that),
849 }
850 
851 template <typename ReturnType, typename... Args>
852 Function<ReturnType(Args...) const> constCastFunction(
853  Function<ReturnType(Args...) const>&& that) noexcept {
854  return std::move(that);
855 }
856 
857 #if FOLLY_HAVE_NOEXCEPT_FUNCTION_TYPE
858 template <typename ReturnType, typename... Args>
859 Function<ReturnType(Args...) const noexcept> constCastFunction(
860  Function<ReturnType(Args...) noexcept>&& that) noexcept {
861  return Function<ReturnType(Args...) const noexcept>{
863 }
864 
865 template <typename ReturnType, typename... Args>
866 Function<ReturnType(Args...) const noexcept> constCastFunction(
867  Function<ReturnType(Args...) const noexcept>&& that) noexcept {
868  return std::move(that);
869 }
870 #endif
871 
892 template <typename FunctionType>
894 
895 template <typename ReturnType, typename... Args>
896 class FunctionRef<ReturnType(Args...)> final {
897  using Call = ReturnType (*)(void*, Args&&...);
898 
899  static ReturnType uninitCall(void*, Args&&...) {
900  throw std::bad_function_call();
901  }
902 
903  template <typename Fun>
904  static ReturnType call(void* object, Args&&... args) {
905  using Pointer = _t<std::add_pointer<Fun>>;
906  return static_cast<ReturnType>(invoke(
907  static_cast<Fun&&>(*static_cast<Pointer>(object)),
908  static_cast<Args&&>(args)...));
909  }
910 
911  void* object_{nullptr};
912  Call call_{&FunctionRef::uninitCall};
913 
914  public:
920  FunctionRef() = default;
921 
925  template <
926  typename Fun,
927  typename std::enable_if<
928  Conjunction<
930  is_invocable_r<ReturnType, Fun&&, Args&&...>>::value,
931  int>::type = 0>
932  constexpr /* implicit */ FunctionRef(Fun&& fun) noexcept
933  // `Fun` may be a const type, in which case we have to do a const_cast
934  // to store the address in a `void*`. This is safe because the `void*`
935  // will be cast back to `Fun*` (which is a const pointer whenever `Fun`
936  // is a const type) inside `FunctionRef::call`
937  : object_(
938  const_cast<void*>(static_cast<void const*>(std::addressof(fun)))),
939  call_(&FunctionRef::call<Fun>) {}
940 
941  ReturnType operator()(Args... args) const {
942  return call_(object_, static_cast<Args&&>(args)...);
943  }
944 
945  constexpr explicit operator bool() const {
946  return object_;
947  }
948 };
949 
950 } // namespace folly
void * ptr
Function & operator=(Fun fun) noexcept(noexcept(/*implicit */Function(std::declval< Fun >())))
Definition: Function.h:720
Function(Member Class::*ptr) noexcept
Definition: Function.h:667
std::function< typename Traits::NonConstSignature > asStdFunction()&&
Definition: Function.h:810
Function(Fun fun) noexcept(IsSmall< Fun >::value &&noexcept(Fun(std::declval< Fun >())))
Definition: Function.h:637
typename std::enable_if< NotFunction< T >::value >::type EnableIfNotFunction
Definition: Function.h:272
bool execSmall(Op o, Data *src, Data *dst)
Definition: Function.h:483
Function(Function &&that) noexcept
Definition: Function.h:601
decltype(std::declval< F >()(std::declval< Args >()...)) CallableResult
Definition: Function.h:286
PskType type
static ReturnType callSmall(Data &p, Args &&...args)
Definition: Function.h:357
static ReturnType callBig(Data &p, Args &&...args)
Definition: Function.h:317
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void swap(Function &that) noexcept
Definition: Function.h:773
static ReturnType uninitCall(Data &, Args &&...)
Definition: Function.h:322
STL namespace.
A reference wrapper for callable objects.
Definition: Function.h:893
constexpr FunctionRef(Fun &&fun) noexcept
Definition: Function.h:932
bool isNullPtrFn(T *p)
Definition: Function.h:277
folly::std T
Function(Function< typename Traits::OtherSignature > &&that, CoerceTag) noexcept
Definition: Function.h:574
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
std::false_type HeapTag
Definition: Function.h:263
SafeResultOf< CallableResult< _t< std::decay< F >> &, Args... >, ReturnType > ResultOf
Definition: Function.h:308
requires E e noexcept(noexcept(s.error(std::move(e))))
Function(Fun &&fun, HeapTag)
Definition: Function.h:563
bool_constant< true > true_type
Definition: gtest-port.h:2210
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
static ReturnType callBig(Data &p, Args &&...args)
Definition: Function.h:363
bool operator!=(const Unexpected< Error > &lhs, const Unexpected< Error > &rhs)
Definition: Expected.h:766
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
Definition: Utility.h:72
constexpr auto invoke(F &&f, Args &&...args) noexcept(noexcept(static_cast< F && >(f)(static_cast< Args && >(args)...))) -> decltype(static_cast< F && >(f)(static_cast< Args && >(args)...))
Definition: Invoke.h:49
std::integral_constant< bool, B > bool_constant
Definition: Traits.h:145
void swap(Function< FunctionType > &lhs, Function< FunctionType > &rhs) noexcept
Definition: Function.h:816
Function(Function< Signature > &&that, CoerceTag)
Definition: Function.h:571
typename T::type _t
Definition: Traits.h:171
std::aligned_storage< 6 *sizeof(void *)>::type tiny
Definition: Function.h:255
static ReturnType uninitCall(void *, Args &&...)
Definition: Function.h:899
Function & operator=(Function< Signature > &&that) noexcept(noexcept(Function(std::move(that))))
Definition: Function.h:741
std::shared_ptr< Function< NonConstSignature > > sp_
Definition: Function.h:332
Function & operator=(Function &&that) noexcept
Definition: Function.h:695
decltype(static_cast< To >(std::declval< From >())) SafeResultOf
Definition: Function.h:293
static const char *const value
Definition: Conv.cpp:50
bool execBig(Op o, Data *src, Data *dst)
Definition: Function.h:499
std::true_type SmallTag
Definition: Function.h:262
void swap(exception_wrapper &a, exception_wrapper &b) noexcept
friend Traits
Definition: Function.h:547
Function< ReturnType(Args...) const > constCastFunction(Function< ReturnType(Args...)> &&) noexcept
Definition: Function.h:845
SafeResultOf< CallableResult< const _t< std::decay< F >> &, Args... >, ReturnType > ResultOf
Definition: Function.h:354
Function & operator=(std::nullptr_t) noexcept
Definition: Function.h:749
bool operator==(const Unexpected< Error > &lhs, const Unexpected< Error > &rhs)
Definition: Expected.h:758
void fun()
auto operator=(Member Class::*ptr) noexcept-> decltype(operator=(std::mem_fn(ptr)))
Definition: Function.h:758
const
Definition: upload.py:398
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
bool_constant< false > false_type
Definition: gtest-port.h:2209
bool exec(Op o, Data *src, Data *dst) const
Definition: Function.h:543
bool hasAllocatedMemory() const noexcept
Definition: Function.h:791
static ReturnType call(void *object, Args &&...args)
Definition: Function.h:904
ReturnType operator()(Args...args) const
Definition: Function.h:941
static ReturnType callSmall(Data &p, Args &&...args)
Definition: Function.h:311
StringPiece data_
Function(std::nullptr_t) noexcept
Definition: Function.h:611
#define FOLLY_FALLTHROUGH
Definition: CppAttributes.h:63
ReturnType(*)(void *, Args &&...) Call
Definition: Function.h:897
Future< bool > call(int depth, Executor *executor)
Function(Function< Signature > &&that) noexcept(noexcept(Function(std::move(that), CoerceTag{})))
Definition: Function.h:653
SharedProxy asSharedProxy()&&
Definition: Function.h:801