FAQ Database Discussion Community


Printing out the hex vale of an unsigned char array in C++

c++,string,hex,std,cout
I want to print out the hex value of an unsigned char array using the cout function. The most obvious approach would be something like the following. unsigned char str[] = "foo bar baz\n"; for(unsigned short int i = 0; i < sizeof(str); i++){ std::cout << std::hex << str[i] <<...

How to print a type vector> to screen c++?

c++,vector,tuples,std
Let's say I have std::vector<std::tuple<string ,int ,int>> tupleVector; tupleVector.push_back(std::tuple<string ,int ,int>("Joe", 2, 3)); tupleVector.push_back(std::tuple<string ,int ,int>("Bob", 4, 5)); How can I iterate on the vector to print all values of this vector containing a tuple?...

E2316 'any_of' is not a member of 'std'

c++,std,c++builder,stl-algorithm,c++builder-6
So I'm trying to use std::any_of() function, but C++ Builder 6 says that there is an error: [C++ Error] Unit1.cpp(93): E2316 'any_of' is not a member of 'std' But I have #include <algorithm> in my Unit1.h #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include...

Can't verify the conversion from time_point to tm and tm back to time_point

c++,std,chrono,ctime
I created a current time_point and converted it to structure tm and printed it's values. Now converted this tm structure to time_point. On comparing the first and second time_points, it is telling that they're different. But the values of structure are exactly same. Can someone spot, where I'm doing wrong?...

How efficient smart pointers are?

c++,pointers,c++11,std
I know, that std::shared_ptr uses reference counting, so it has copy&move semantics, on the other hand std::unique_ptr (hence the name unique) only has move semantics, so trying to copy it is a compile error. However, its not quite clear for me how big of a deal is that. Can I...

How to make function like operator