This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Do I need to protect read access to an STL container in a multithreading environment?
I am using the C++ standard library which comes with (Linux) GCC or (Windows) VC.
Can anyone please say clearly whether or not this library is thread safe?
"Thread safe" is not a clearly-defined boolean property of a library. Some things can be done concurrently and others cannot.
Almost certainly if you were to ask a more detailed question specifying what it is you want to do, the answer would be "no, it is not thread-safe". But only almost.
If by "thread-safe" you mean something like the difference between Vector and ArrayList in Java, then C++ standard containers are non-thread-safe.
Related
This question already has answers here:
Is there a C++ equivalent to getcwd?
(8 answers)
Closed 2 years ago.
I'am familiar that getcwd() function is available in c to get current working directory.Is there a std function in cpp for the same?
Yes.
C++17 has std::filesystem::current_path.
On a POSIX system, you can also just keep using getcwd(). getcwd() is not actually part of C. Even it were, you could still keep using it, as the C Standard Library is available in C++; however, you've probably heard that it is preferable to use the C++ Standard Library where possible, and that's largely true.
Use current_path() method in boost::filesystem or std::filesystem::current_path() in c++17
This question already has answers here:
Is there any cross-platform threading library in C++?
(12 answers)
Closed 8 years ago.
C++11's threading library is wonderful looking. It's small, simple, standard, and portable. Unfortunately, I'm locked to Visual Studio 2010 which obviously doesn't have that available to it.
My questions are, what multi-threading libraries are available that provide a similar level of functionality, while being portable and reliable? Is it possible (physically and legally) to obtain the corresponding <thread> library to use in VS2010? Are there disadvantages to using a separate library (maybe not as actively maintained since C++11 fills that role, etc)?
First, take a look on wikipedia list of C++ multi-threading libraries. Some very well documented library can by POCO C++. However, you can also see related question Is there any cross-platform threading library in C++?.
This question already has answers here:
What C++ Smart Pointer Implementations are available?
(3 answers)
Closed 8 years ago.
These three are shared pointer classes from Qt, STL and Boost, respectively. They seem to be identical in functionality so I'm puzzled as to:
What are advantages and disadvantages of each of them?
Why do Boost and Qt versions even exist -- it was in STL already, why make your own?
How should I choose which one to use?
Look here for the answers to your questions.
QSharedPointer requires Qt, shared_ptr is standard and portable
std::shared_ptr is a standard replacement for boost::shared_ptr (that is, the boost one came first and it became standard)
Don't use QSharedPointer unless you have a Qt class that requires it. If you have a tr1, or C++0x implementation use std::shared_ptr, otherwise used boost::shared_ptr.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
C Analog To STL
Is there something like STL for C.
You can have a look at the glib, which provides lots of interesting features
well there is the C library of course :) but I do not see the use of templates for C
There's not really anything quite like the STL; but there are a lot of libraries. glib has been mentioned, but usually it's not always useable together with whatever libraries you are using for actually achieving what you want to do.
This question already has answers here:
Closed 13 years ago.
Possible Duplicates:
Hashtable in C++?
can anybody offer a simple hash_map example in C++?
Does the STL contain an implementation of a hashtable?
If so, can you provide a brief example of how to use it?
Current standard implementation doesn't, STL::TR1 does, see Unordered Map.
Most modern compilers have a TR1 implementation, if that fails, you may always use the Boost TR1 implementation.
MSVC has it for VS2008 via service pack 1
GCC has it shipped with 4.x, but you can make it work with 3.4.x too AFAIR
Usage is almost the same as with a std::map.
While not officially part of the STL standard, hash_map and hash_set are commonly used to improve searching times......
http://msdn.microsoft.com/en-us/library/0d462wfh%28VS.80%29.aspx
So, long story short--no .
A quick google came up with this description of hash_map.