English 中文(简体)
哪些行动已read:地图?
原标题:What operations are thread-safe on std::map?

附录一

stl::map<std::string, Foo> myMap;

以下职能是否安全?

myMap["xyz"] ?

页: 1 我想把这一巨大的读写地图分给许多座右铭,但我不知道,即便是搜索,还是安全。


一切都首先写成。

之后,从中读到多个读物。

我试图避免锁锁,使之成为尽可能的fa。 (我知道,亚于可能过早优化)

最佳回答

从理论上讲,没有任何STL集装箱可穿透。 在实践中,如果不同时修改集装箱,读书是安全的。 也就是说,标准没有说明胎面。 下一版标准意愿和第二版准则将保证安全阅读的行为。

如果你真的担心,就使用一种双轨搜索的分体。

问题回答

C++11要求被宣布为const的所有成员职能为多个读者的阅读安全。

Calling myMap["xyz"] is not thread-safe, as std::map::operator[] isn t declared as const. Calling myMap.at("xyz") is thread-safe though, as std::map::at is declared as const.

从理论上讲,光读的数据结构和功能并不要求任何24小时的翻新安全。 它是内在的。 共有没有数据竞赛。 然而,你必须保证安全开端。

As S. 指出,主要实施如下图中的一项内容:www.roc.map[`xyz'] :_t_p.htm 如果是,那是安全的。 但是,你必须再次保证,除了最初的阶段外,没有改变结构的线索。

STL收集器是铁 t,但很简单,可以把安全添加到一起。

你们的最好灯塔是围绕有关藏书建立一个read子。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签