我有以下功能对象:
/// function object wrapping node and label data into strings of DOT code
/// requires as template parameters 2 function objects that define behaviour
/// converting node and lable into strings. Requires as first template
/// argument the graph edge type
template<typename GRAPHEDGE, typename NodeToStringConverter,
typename LabelToStringConverter>
struct DOTWrapper
{
typedef NodeToStringConverter NodeConverter;
typedef LabelToStringConverter LabelConverter;
/// initialises to-string-converter objects
DOTWrapper(NodeConverter& nc, LabelConverter& lc): nts(nc), lts(lc){}
std::string start() const
{
return ("digraph {\n");
}
// wrap an egde into dot code
std::string wrap_edge(const GRAPHEDGE& e) const
{
// n needs to be to_string-able
return ("\t\""+nts(e.source())+"\""+" -> "+"\""+nts(e.target())+"\""+
" [ label = \""+lts(e.label())+"\" ];\n");
}
std::string finish() const { return "}\n"; }
const NodeToStringConverter nts;
const LabelToStringConverter lts;
};
template<typename Node>
struct NTSint
{
std::string operator()(const Node& node) const { return node; }
};
template<typename Label>
struct LTSstr
{
std::string operator()(const Label& label) const { return label; }
};
当我尝试像这样实例化一个Wrapper对象时:
typedef NTSint<Edge::Node> NConv;
typedef LTSstr<Edge::Label> LConv;
typedef DOTWrapper<Edge, NConv, LConv> DOTf;
const DOTf dotf((NConv()), (LConv()));
我得到了
“错误:没有用于初始化的匹配构造函数 'const DOTf'(又名'const DOTWrapper') const DOTf dotf((NConv()),(LConv()));“
为什么?毕竟NConv和LConv在内存中占有一席之地......所以...它们不应该是l值吗?