2

So i have this: boost::array data_;

How do i convert it to normal BYTE/Char buffer or how do i print the data inside without converting it , using printf?

How can i compare it with other normal chracter buffer for example "hello". It will be also very helpfull to know how does boost::array work, (i am creating boost async.tcp server).

I have tried some things but i was unable to print the characters inside the buffer, i'm new to boost.

I could not find much documentation about boost.

Thank you.

1 Answers1

1

The boost::array class is a parameterized type, meaning that the full type name of a variable of this type is something like boost::array<char,10> for an array containing 10 elements of type char, or boost::array<float,100> for an array containing 100 elements of type float.

If you happen to have a variable data_ of some type boost::array<T,N> where T is char, then printing out the characters in it is easy:

std::cout.write(data_.data(), data_.size());

If T is wchar, you could do

std::wcout.write(data_.data(), data_.size());

If your particular boost::array type contains some other element type T, you need to consider how you would want to print out the elements. For example, if your happy with the default stream representation of the type, you may do something like

for (auto element : _data) {
    std::cout << element << "\n";
}

to print out one element per line.

You can find the documentation of the boost::array class at http://www.boost.org/doc/libs/1_53_0/doc/html/boost/array.html

Rolf W. Rasmussen
  • 1,909
  • 1
  • 12
  • 9