asio-tr2
asio-tr2 copied to clipboard
Think about how to avoid heap allocation when accessing resolver entry host name and service name
Have a look at string_view's to_string which is templated on allocator type.
Consider also adding same facility to ip::host_name().
Applied in 3f0f21c3fa02b1406bbb1fff7219b2d48afc2f87.
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.