使用std::function,我们可以使用得到一个参数的类型argument_type,second_argument_type等等类型定义,但我看不到的方式做同样的事情lambda表达式.可能吗?(我正在使用VS2010)
假设我想要在我的反序列化系统中使用以下内容来读取对象并将其传递给setter函数:
template<typename F>
static void forward(F f)
{
// Create an object of the type of the first
// parameter to the function object F
typedef typename F::argument_type T;
T t;
//...do something with 't' here (deserialize in my case)
// Forward the object to the function
f(t);
}
Run Code Online (Sandbox Code Playgroud)
它可以像这样使用,一切正常:
std::function<void(int)> f = [](int i) -> void { setValue(i); };
forward(f);
Run Code Online (Sandbox Code Playgroud)
但它不能直接与lambdas一起使用:
forward([](int i) -> void { setValue(i); });
//error C2039: 'argument_type' : …Run Code Online (Sandbox Code Playgroud) 我应该在 UWP Xaml Slider 上监听哪些事件来确定用户何时开始和结束操作。
当您有一个代表某些不断变化的应用程序状态(例如动画时间)的滑块并且您希望在用户与滑块交互时暂停更新时,此功能非常重要。
此问题已针对 WPF 和 Windows Phone 得到解答,但尚未针对 UWP 得到解答。其他解决方案对于 UWP 不起作用或不完整。