C++ template to cover const and non-const method

后端 未结 7 1493
北荒
北荒 2020-12-29 22:48

I have a problem with duplication of identical code for const and non-const versions. I can illustrate the problem with some code. Here are two s

7条回答
  •  情歌与酒
    2020-12-29 23:21

    You could use const_cast and change VisitorRead's method signature so it also take's const T& as a parameter, but I think that is an ugly solution.

提交回复
热议问题