Questions tagged [std]

The C++ Standard Library, and its namespace. Use in conjunction with [c++].

From Wikipedia

The C++ Standard Library provides several generic containers, functions to utilise and manipulate these containers, function objects, generic strings and streams (including interactive and file I/O).

http://en.wikipedia.org/wiki/C++_Standard_Library

The concept of using namespaces

http://en.wikipedia.org/wiki/Namespace_(computer_science)

Also see

4970 questions
3
votes
2 answers

Thread safety of std::mutex

Can I lock std::mutex in one thread and unlock it in other thread? This is theoretical question without any specific engineering context. I am just curious.
Trismegistos
  • 3,821
  • 2
  • 24
  • 41
3
votes
2 answers

trying to understand std::cin.get()

Hi all so i was reading about std::cin.get() func and read that we use it to capture the newline char that was entered after entering any input to the console. But i kind of got confused while writing a small very basic program and couldn't…
Puneet Mittal
  • 532
  • 1
  • 15
  • 24
3
votes
3 answers

Which is the right container to manage small objects which map to some other small objects?

I have a set of small objects. Each of these objects points to other objects. These pointers might be realized as actual pointers or as index into an array of the objects or something else. It might be an array of such pointers whose length might…
Michael
  • 7,407
  • 8
  • 41
  • 84
3
votes
3 answers

C++11 Random between int x, int y, excluding list

I need a way to generate random integers between x,y, but once a random z is generated, I need the next iteration of x,y to exclude z (or better yet, a list of ints to exclude). The return value has to honor the "std::uniform_int_distribution<>"…
Ivan
  • 7,448
  • 14
  • 69
  • 134
3
votes
4 answers

C++ random access iterators for containers with elements loaded on demand

I'm currently working on a small project which requires loading messages from a file. The messages are stored sequentially in the file and files can become huge, so loading the entire file content into memory is unrewarding. Therefore we decided to…
chrish.
  • 715
  • 5
  • 11
3
votes
1 answer

Right way to allocate and release memory for array of objects that I will use in a std::map

I have a collection of polygons that I retrieve from the database and which I wish to store in a binary tree for fast accessing. As a binary tree I use std::map. I created this solution, which is outlined below, but I think that it is not correct…
Rauni Lillemets
  • 2,299
  • 1
  • 26
  • 39
3
votes
2 answers

How to check in C# if the given double number is normal, i.e. is neither zero, subnormal, infinite, nor NaN

How to check in C# if the given double number is normal, i.e. is neither zero, subnormal, infinite, nor NaN. In C++ there was a method std::isnormal which was exactly checking this condition. Is there an equivalent in C#?
Sebastian Widz
  • 1,962
  • 4
  • 26
  • 45
3
votes
3 answers

resize with custom allocator

How can I resize a std::vector by using a custom allocator and not the copy constructor? Here is what I tried: #include #include class A{ public: A(int x){ std::cout<<" new a:"<
Fabio Dalla Libera
  • 1,297
  • 1
  • 10
  • 24
3
votes
4 answers

Better way to convert a vector of uint8 to an ascii hexadecimal string

I coded the following function to convert a std::vector of uint8_t to an ascii hexadecimal string (gnu++98 standard). ... string uint8_vector_to_hex_string(const vector& v) { stringstream ss; vector::const_iterator it; …
Filippo Lauria
  • 1,965
  • 14
  • 20
3
votes
2 answers

Includes not found for clang++ + OpenMP + stdlibc++

I followed the excellent walkthrough on how to compile clang(++) with OpenMP support for Mac OS X found here. However, while compiling a simple test program: #include int main(int argc, char** argv) { std::cout << "Hello world!" <<…
gustafbstrom
  • 1,622
  • 4
  • 25
  • 44
3
votes
1 answer

Compiler error when instantiating std::mutex

I have used std::mutex extensively in my codebase. However, one of the classes simply does not let me add a mutex to its instance variables list. I am instantiating the mutex quite simply using the following - std::mutex myMutex; I added the above…
The Vivandiere
  • 3,059
  • 3
  • 28
  • 50
3
votes
2 answers

How does shared_ptr detect that T derives from enable_shared_from_this?

I am trying to learn how shared_ptr works by implementing it from scratch, and I can't figure out how to detect T's base class. I've tried using is_base_of(), but that gives a const value, which I can't use with an if statement to set the object's…
Alex
  • 846
  • 6
  • 16
3
votes
1 answer

Functions in namespace std accessible in global scope

Under some situations, it seems like I can access functions that should be in the std namespace without a using or std:: qualifier. So far, I've only seen this occur with functions from the algorithm library. In the following example, I expect…
fractalic
  • 387
  • 2
  • 10
3
votes
3 answers

Converting a struct to an array

As programming becomes more complex, and the need to perform operations on struct data becomes visible. Is there a conversion method for converting a struct type into an array of its members such that: struct FooDesc Foo{ int num_Foo; int…
Rashid Ellis
  • 330
  • 3
  • 22
3
votes
2 answers

Change the list item

Sorry for my English. Some class: class Kid { public: ... string _name; std::list _cuteKids; }; Use class: std::list kids; kids.push_back(new Kid("Jeck")); kids.push_back(new Kid("Anna")); kids.push_back(new…
Tipok
  • 675
  • 8
  • 26