假设我有以下对象:
struct Foo { int size() { return 2; } };
什么是获得size所有对象总数的最佳方式(最可维护,可读等)vector<Foo>?我会发布我的解决方案,但我对更好的想法感兴趣.
size
vector<Foo>
更新:
到目前为止,我们有:
还有其他可行的解决方案吗?你可以使用boost::bind或制作可维护的东西std::bind1st/2nd吗?
boost::bind
std::bind1st/2nd
c++ containers stl member-functions
c++ ×1
containers ×1
member-functions ×1
stl ×1