: observer_(observer),
snapshot_([&] { return new Snapshot<T>(observer_.getSnapshot()); }) {}
+template <typename T>
+TLObserver<T>::TLObserver(const TLObserver<T>& other)
+ : TLObserver(other.observer_) {}
+
template <typename T>
const Snapshot<T>& TLObserver<T>::getSnapshotRef() const {
auto& snapshot = *snapshot_;
class TLObserver {
public:
explicit TLObserver(Observer<T> observer);
+ TLObserver(const TLObserver<T>& other);
const Snapshot<T>& getSnapshotRef() const;
const Snapshot<T>& operator*() const {
}
});
}
+
+TEST(Observer, TLObserver) {
+ auto createTLObserver = [](int value) {
+ return folly::observer::makeTLObserver([=] { return value; });
+ };
+
+ auto k =
+ std::make_unique<folly::observer::TLObserver<int>>(createTLObserver(42));
+ EXPECT_EQ(42, ***k);
+ k = std::make_unique<folly::observer::TLObserver<int>>(createTLObserver(41));
+ EXPECT_EQ(41, ***k);
+}