Immutable list

Hello everyone,
I wonder if there is a standard way to get immutable list from regular STL list.
A fail-safe list is better but I would appreciate any suggestions)
Thanks in advance.
Ideas that come to mind are to make it available only as a const reference, or give only a const_iterator to it.
1
2
3
4
5
6
7
8
#include <list>

int main()
{
    std::list<int> mutable_list = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

    const std::list<int> immutable_list(mutable_list);
}


A fail-safe list

I don't know what a "fail-safe" list is. It doesn't really make sense to me in terms of a container and google isn't helpful.
Topic archived. No new replies allowed.