【folly】folly::partial

folly::partial

 

#include <folly/Functional.h>
#include <iostream>

void print(int a, int b, int c) {
    std::cout << a << ", " << b << ", " << c << std::endl;
}

int main() {
    auto f = folly::partial(print, 1, folly::placeholders::_1, 3);
    f(2); // 输出:1, 2, 3
}

 

#include <folly/Functional.h>
#include <functional>
#include <iostream>

int add(int x, int y) {
    return x + y;
}

int main() {
    std::function<int(int)> f = folly::partial(add, 10, folly::placeholders::_1);
    std::cout << f(5) << std::endl;  // 输出 15
}

 

posted @ 2025-07-25 09:39  苏格拉底的落泪  阅读(9)  评论(0)    收藏  举报