mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Summary: `SharedFunction` implements a pattern of a shared callable object that contains the same executable inside. It's similar to `std::function` with one important difference: when the object is copied, the stored function (and captured values) are shared between instances (not copied). `SharedFunction` can be stored inside `std::function` because it's callable. It useful in some scenarios, such as: * When captured by `std::function` arguments are not copyable; * When we need to replace the content of the callable later on the go. We will use it in the coming diffs. Reviewed By: mdvacca Differential Revision: D14072078 fbshipit-source-id: 9df4ad2d1b92394e2dfef5c283f35c7c0bd4b500
20 lines
474 B
C++
20 lines
474 B
C++
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
inline bool floatEquality(float a, float b, float epsilon = 0.005f) {
|
|
return (std::isnan(a) && std::isnan(b)) ||
|
|
(!std::isnan(a) && !std::isnan(b) && fabs(a - b) < epsilon);
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|