functor

    -1热度

    1回答

    我有点新的C++ 11和我读到this一篇关于仿函数,这是非常有帮助的,我只是认为这是有可能使接收多单变量更多的是仿函数? 例如我们有下面的类: class my_functor{ public: my_functor(int a,int b):a(a),b(b){} int operator()(int y) { return a*y; }

    0热度

    1回答

    我试图用Thrust创建设备仿函数,它将存储对设备数据结构的引用作为它们的状态。函子然后会被传入thrust::transform()和朋友。问题是我收到关于在仿函数的return声明呼吁从设备码中的主机功能错误: // Compile with: // nvcc --std=c++11 device_functor.cu -o device_functor #include <thrust

    0热度

    2回答

    只要我的线程执行,就需要使用此Functor,所以我创建了一个shared_ptr并试图将它传递给std :: thread 。我在这里复制了代码和错误列表。 struct Functor { std::string greeting; explicit Functor(std::string _greeting="Hello!"): greeting { _greeting

    4热度

    1回答

    标准ML中是否有可能重新导出作为函数参数接收的结构的一部分的数据类型的构造函数。某些代码可能会使这更容易理解: signature FLAG = sig type t end signature MEMBER = sig structure Flag : FLAG end functor Member(F : FLAG) : ME

    0热度

    1回答

    我已经得到了以下数据类型: data Users id height weight = User id height weight instance Functor Users where fmap f (User id height weight) = User(f id height weight) 然而,这不会编译? 当我使用一个类型与一个单一的参数,如它正常工作: data Us

    0热度

    1回答

    所以我想使用对象函数对子类中的数组进行排序。母类是通用的。 template<typename T> class MotherClass { public: /* some code */ std::list<T*> getList(); private: std::list<T*> list_; } 子类使用另一个类为模板 class OtherC

    1热度

    1回答

    我是一个新的函数式编程。我正在使用Scalpel刮掉一个网站,我需要从该网站中包含的链接中提取信息。我可以推断,但只是链接的一部分,我需要添加到字符串"http://www.google.com/"每个这些链接。我不能做一个正常的++,因为我没有String的列表。 下面的代码: {-# LANGUAGE OverloadedStrings #-} import Text.HTML.Scalp

    7热度

    1回答

    Control.Monad.Morph包括 class MFunctor t where hoist :: Monad m => (forall a. m a -> n a) -> t m b -> t n b 据我所知,没有一个包括实例的使用Monad m约束。人们会怎么做?是否有有效的实例使用约束条件(对于我来说,想象一下hoist id = id)有多难?约束条件对m有什么意义

    0热度

    1回答

    如果我有这样的: ?:check_dv([v(1,x),v(2,y)], X). 我如何检查什么是第二个参数,例如v(1,x)(在这种情况下x)? 一旦我有了名单的头:[Head | Tail],与Head = [v(1,x)],我该如何检查它?

    1热度

    3回答

    我对函数没有经验,并试图在某种程度上理解基础知识。我想要的只是一个函子,它将接收一个字符串并返回相同的字符串,并将所有值更改为大写。我有以下代码: #include "stdafx.h" #include <iostream> #include <string> #include <string.h> #include <algorithm> using namespace std;