我有一个实现cbegin()和cend()功能的自定义容器类。然后我在 foreach 循环中使用它,但它似乎需要begin()和end()成员函数,即使我尝试使用const修饰符:
for (const auto val: container)
像这样:
for (auto const val: container)
像这样:
for (const auto const val: container)
是否可以强制 foreach 使用常量 c 函数?