diff options
Diffstat (limited to 'boost/asio/ip/basic_resolver_entry.hpp')
-rw-r--r-- | boost/asio/ip/basic_resolver_entry.hpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/boost/asio/ip/basic_resolver_entry.hpp b/boost/asio/ip/basic_resolver_entry.hpp index 05c8547a0c..ec6c7bd6d5 100644 --- a/boost/asio/ip/basic_resolver_entry.hpp +++ b/boost/asio/ip/basic_resolver_entry.hpp @@ -17,6 +17,7 @@ #include <boost/asio/detail/config.hpp> #include <string> +#include <boost/asio/detail/string_view.hpp> #include <boost/asio/detail/push_options.hpp> @@ -50,10 +51,10 @@ public: /// Construct with specified endpoint, host name and service name. basic_resolver_entry(const endpoint_type& ep, - const std::string& host, const std::string& service) + BOOST_ASIO_STRING_VIEW_PARAM host, BOOST_ASIO_STRING_VIEW_PARAM service) : endpoint_(ep), - host_name_(host), - service_name_(service) + host_name_(static_cast<std::string>(host)), + service_name_(static_cast<std::string>(service)) { } @@ -75,12 +76,30 @@ public: return host_name_; } + /// Get the host name associated with the entry. + template <class Allocator> + std::basic_string<char, std::char_traits<char>, Allocator> host_name( + const Allocator& alloc = Allocator()) const + { + return std::basic_string<char, std::char_traits<char>, Allocator>( + host_name_.c_str(), alloc); + } + /// Get the service name associated with the entry. std::string service_name() const { return service_name_; } + /// Get the service name associated with the entry. + template <class Allocator> + std::basic_string<char, std::char_traits<char>, Allocator> service_name( + const Allocator& alloc = Allocator()) const + { + return std::basic_string<char, std::char_traits<char>, Allocator>( + service_name_.c_str(), alloc); + } + private: endpoint_type endpoint_; std::string host_name_; |