簡體   English   中英

如何獲得通過重載解析選擇的函子簽名?

[英]How do I get the functor signature selected by overload resolution?

我想獲取給定參數的任意類型的operator()的類型。

template<typename F, typename... Args>
constexpr auto call_ptr =
    static_cast<std::invoke_result_t<F, Args...> (F::*)(Args...)>(&F::operator());

但是, call_ptr不適用於重載解析。 例如,這些都失敗了

struct S {
    void operator()(double) {}
    void operator()(int) {}
};
call_ptr<S, char>;

call_ptr<decltype([](auto&&){}), int>;

我該怎么寫call_ptr

無法執行此操作,但是建議將此功能添加到語言中: http : //www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3866.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM