【发布时间】:2011-06-06 14:29:53
【问题描述】:
我有这个枚举(类)
enum class conditional_operator
{
plus_op,
or_op,
not_op
}
我想要一个代表这些映射的std::map:
std::map<conditional_operator, std::binary_function<bool,bool,bool>> conditional_map =
{ { conditional_operator::plus_op, std::logical_and<bool> },
{ conditional_operator::or_op, std::logical_or<bool>},
{ conditional_operator::not_op, std::binary_negate<bool>} // this seems fishy too, binary_negate is not really what I want :(
除了这不能编译:
错误:'}' 标记之前的预期主表达式
错误:'}' 标记之前的预期主表达式
错误:'}' 标记之前的预期主表达式
对于三行中的每一行,我应该怎么做?我认为带有第二个虚拟参数的logical_not 会起作用,当然,一旦我得到它来编译......
编辑:我可以为此使用 lambda 吗?
【问题讨论】:
标签: c++ map c++11 functional-programming