summaryrefslogtreecommitdiff
path: root/absl/functional
diff options
context:
space:
mode:
Diffstat (limited to 'absl/functional')
-rw-r--r--absl/functional/bind_front_test.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/absl/functional/bind_front_test.cc b/absl/functional/bind_front_test.cc
index 4801a81c..92b6e8e5 100644
--- a/absl/functional/bind_front_test.cc
+++ b/absl/functional/bind_front_test.cc
@@ -228,4 +228,23 @@ TEST(BindTest, Mangling) {
absl::bind_front(ManglingCall{}, 1, 3.3)("A");
}
+struct Adder {
+ int add(int v2) const { return v + v2; }
+ int v;
+};
+
+TEST(BindTest, InvokeSemantics) {
+ Struct s1 = {"value"};
+ auto f1 = absl::bind_front(&Struct::value);
+ EXPECT_EQ(f1(s1), "value");
+ EXPECT_EQ(f1(&s1), "value");
+ EXPECT_EQ(f1(std::ref(s1)), "value");
+
+ Adder add_100 = {100};
+ auto f2 = absl::bind_front(&Adder::add);
+ EXPECT_EQ(f2(add_100, 23), 123);
+ EXPECT_EQ(f2(&add_100, 45), 145);
+ EXPECT_EQ(f2(std::ref(add_100), 67), 167);
+}
+
} // namespace