问题标签 [boost-lambda]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
321 浏览

boost - 这个 boost::lambda::bind 用法有什么问题?

这段代码有问题吗?我不断收到编译错误。基本上我想将一个 void 返回函数连接到一个具有非 void 返回类型的信号。增强版:1.46.1 版

编译时出现以下错误:

谢谢。

0 投票
1 回答
604 浏览

c++ - 在 boost::lambda 中表达 _1.second->pair().first == r

我有一个需要std::transform作为回调输入的表达式,但我不想为它编写另一个方法。_1.second->pair().first == r我想表达boost::lambda假设_1是唯一传递给它的参数类型的表达式std::pair

我有一个通用的速记函子util::shorthand::pair_secondutil::shorthand::pair_first它返回一对中的第二个和第一个项目。

我可以做boost::bind(util::shorthand::pair_second, _1)但是然后做什么?如何实现表达式的其余部分?

-1.second是模板类型的Connection<T>。我不能使用 C++11

0 投票
3 回答
970 浏览

c++ - 与 C++11 lambda 相比,bind() 是否有任何优势(除了兼容性)?

我正在考虑将我的代码迁移到使用 C++11 风格的 lambda,而不是bind到处都有 s 。但我不确定这是否是个好主意。

与 C++11 风格的 lambda 相比,使用 eg boost::lambda(or boost::phoenix) 有什么实际优势吗?

转移到 lambdas 是个好主意吗?我是否应该迁移我的代码?

0 投票
1 回答
198 浏览

c++ - Boost::Lambda 中的 ref()?

refBoost::Lambda 中的 Boost::Phoenix 的等价物是什么?我在在线文档中找不到它。

boost::ref并且boost::lambda::var似乎不起作用(显然,它们没有运算符重载)。

0 投票
0 回答
154 浏览

c++ - 在 Boost.Lambda 中使用自定义下标运算符

我正在使用 Visual Studio 2005 和 Boost 1.37。我还在 Visual Studio 2012 Express Desktop 和 Boost 1.50 上测试了相同的代码,但没有成功。

我想通过访问我的类型上的自定义下标运算符来使用Boost.Lambda 。与std::array一起使用时也会发生这种情况,因此我将说明std::array类型的问题:

错误是:

我找到了这个页面:Extended return type deduction system

但我无法成功实施。

有谁知道在这里可以做什么?

0 投票
3 回答
315 浏览

haskell - 哪种函数式语言方法最容易转移到 Boost Phoenix?

我希望通过 am 学习函数式编程,以便将 Boost.phoenix 集成到我的项目中。

哪种语言最相似,因此我可以找到能够以可以在该上下文中轻松应用的方式说明函数式编程概念的书籍... haskell 和 ocaml 相似吗?

或者,有没有什么好的函数式编程书籍可以应用到 Boost.phoenix?

0 投票
2 回答
187 浏览

c++ - 使用 boost lambda 设置结构的成员

我正在尝试使用vector<Wrap>与中相同的值进行创建v。我尝试了以下组合,没有奏效!

注意:还不能使用 C++11

更新任何适用于 C++03 的干净解决方案都可以。不需要使用 boost lambda

0 投票
1 回答
160 浏览

c++ - 如何使用 boost::lambda 为现有指针创建新对象?

我想要做的是 --> 在新线程中创建一个新对象。就像是:

它不编译,什么是正确的方法?

0 投票
2 回答
124 浏览

c++ - 提升 lambda 递归?

boost::lambda 可以递归使用吗?

这不编译:

有建议的解决方法吗?

编辑:关于使用 C++11 lambdas:以下内容无法在 VS2012 上编译:

另一个编辑:奇怪的是,这个工作正常:

0 投票
1 回答
1983 浏览

c++ - C++: how to find max_element using boost::range?

I am trying to return an iterator to the largest element in a filtered range. Here is what I have so far:

I expected the code to print out the index in the vector x which has the largest element (ie 2), but unfortunately it does not compile (Linux 64bit, GCC 4.7.2), the problem being in the line indicated above. The first compilation error I get from the compiler (amongst others) is the following:

/boost/tuple/detail/tuple_basic.hpp:396:36: error: assignment of read-only member ‘boost::tuples::cons::head’</p>

Any ideas what I am doing wrong? Or how else I can achieve what I am trying to do? Thanks in advance!

EDIT:

Changing the problematic line to :

seems to return the iterator to the largest element. However, is there a way to check that the iterator is within the range? Comparing it with boost::end(x) gives me an error. The only thing I can think of is to return

and check if boost::empty(another_range). Is this the only option? Thanks.