asio-tr2 icon indicating copy to clipboard operation
asio-tr2 copied to clipboard

Think about how to avoid heap allocation when accessing resolver entry host name and service name

Open chriskohlhoff opened this issue 10 years ago • 3 comments

Have a look at string_view's to_string which is templated on allocator type.

chriskohlhoff avatar Feb 27 '15 13:02 chriskohlhoff

Consider also adding same facility to ip::host_name().

chriskohlhoff avatar Feb 27 '15 13:02 chriskohlhoff

Applied in 3f0f21c3fa02b1406bbb1fff7219b2d48afc2f87.

chriskohlhoff avatar Apr 12 '15 02:04 chriskohlhoff

Pre-Lenexa Summary

[internet.resolver.entry], [internet.host.name]

The basic_resolver_entry member functions have been changes as follows:

template<class Allocator = allocator<char>>
  basic_string<char, char_traits<char>, Allocator>
    host_name(const Allocator& a = Allocator()) const;
template<class Allocator = allocator<char>>
  basic_string<char, char_traits<char>, Allocator>
    service_name(const Allocator& a = Allocator()) const;

Similarly host_name was changed as follows:

string host_name();
string host_name(error_code& ec);
template<class Allocator>
  basic_string<char, char_traits<char>, Allocator>
    host_name(const Allocator& a) const;
template<class Allocator>
  basic_string<char, char_traits<char>, Allocator>
    host_name(const Allocator& a, error_code& ec) const;

LEWG to confirm if this is the right approach.

The change was included in revision 5. An implementation can be found on the master branch of Asio's GitHub repository.

chriskohlhoff avatar May 04 '15 10:05 chriskohlhoff