4

我做了一些类似于创建一个structforphoenix::function

struct to_upper_impl
{
  template <typename T1>
  struct result { typedef std::string type; };

  std::string operator()(const std::string & s) const
  {
    return boost::algorithm::to_upper_copy(s);
  }
};

boost::phoenix::function<to_upper_impl> to_upper;

然后在我的语义操作中使用该功能。

我想知道是否可以在我的语义代码中使用某种单行代码(而不是创建结构)?

谢谢!

4

1 回答 1

1

据我所知 - 没有。到目前为止,没有其他方法可以将其他可调用类型作为参数传递给 phoenix::function。当我尝试使用它时,我尝试使用 C++11 lambda,但由于 Boost.ResultOf 协议,尝试使用一些参数调用 phoenix::function 时失败了。你可以在这个线程中看到解释: Can't call a lazy lambda function with parameters via boost::phoenix::function

使用 boost(BLL) 和 phoenix lambdas 并没有更短和更轻。所以目前还没有好的选择。

于 2012-10-21T11:29:55.053 回答