Templates accepting “anything” in C++

后端 未结 4 788
[愿得一人]
[愿得一人] 2021-01-12 05:53

I have a simple template struct associating a string with a value

template struct Field
{
    std::string name; T self;
}

4条回答
  •  北海茫月
    2021-01-12 06:19

    This is not very idiomatic for C++. It can be done, perhaps; Coplien's book might have some ideas. But C++ is strongly typed because it believes in typing; trying to turn it into Smalltalk or fold it like a pheasant may lead to tears.

提交回复
热议问题