Well, the best way is to use the following constructor:
template<class InputIterator> string (InputIterator begin, InputIterator end);
which would lead to something like:
std::vector<char> v;
std::string str(v.begin(), v.end());
More Related Contents:
- What is a vector of vector of point? [closed]
- Complete noob :Error3error C4700: uninitialized local variable radius used [closed]
- “std::endl” vs “\n”
- Why does this C++ snippet compile (non-void function does not return a value) [duplicate]
- Reader/Writer Locks in C++
- Advantages of using std::make_unique over new operator [duplicate]
- C++ Detect when user presses arrow key
- Unnecessary curly braces in C++
- Unicode Processing in C++
- Why does auto x{3} deduce an initializer_list?
- Why is the copy constructor not called?
- Template tuple – calling a function on each element
- When is an object “out of scope”?
- Why does this delay-loop start to run faster after several iterations with no sleep?
- Waitpid equivalent with timeout?
- Understanding the example on lvalue-to-rvalue conversion
- Unoptimized clang++ code generates unneeded “movl $0, -4(%rbp)” in a trivial main()
- What is the fastest way to change a key of an element inside std::map
- Convert C++ function pointer to c function pointer
- C++ parameter pack, constrained to have instances of a single type?
- Critique my non-intrusive heap debugger
- How to detect IP address change programmatically in Linux?
- Is an iterator in C++ a pointer?
- Unbuffered output with cout
- iterator adapter to iterate just the values in a map?
- How to initialize a struct to 0 in C++
- Differences between running an executable with Visual Studio debugger vs without debugger
- Is there a case where including the same header twice is actually helpful?
- Undefined reference error with new filesystem library and clang++7
- popen equivalent in c++