2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

c++ > STL勉強 > cbegin() / cend() > constnessの保証

Last updated at Posted at 2016-02-03

http://qiita.com/SaitoAtsushi/items/d26a5cfa5453d8d91b63
のコードを参考に STL や template を勉強中。

今回目に止まって自分が知らなかったものは

template<class T>
typename continuous<T>::const_iterator continuous<T>::begin(void) const {
  return data.cbegin();
}

のcbegin()というメソッド。

以下を見つけた。
http://stackoverflow.com/questions/12001410/what-is-the-reason-behind-cbegin-cend

Now, we have syntactic assurances that SomeFunctor cannot modify the elements of the vector (without a const-cast, of course).

普通のbegin()/end()を使った場合は要素のconstnessが保証できないので、cbegin()/cend()が導入された、という僕の解釈。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?