44** Author Francois Michaut
55**
66** Started on Sun Feb 13 17:09:05 2022 Francois Michaut
7- ** Last update Wed Aug 20 12:57:17 2025 Francois Michaut
7+ ** Last update Sat Jun 20 09: 12:58 2026 Francois Michaut
88**
99** Address.hpp : Interface to represent network addresses
1010*/
1111
1212#pragma once
1313
1414#include < cstdint>
15+ #include < memory>
1516#include < string>
1617#include < type_traits>
1718
@@ -35,21 +36,29 @@ namespace CppSockets {
3536 [[nodiscard]] virtual auto get_addr () const -> const IAddress & = 0;
3637 [[nodiscard]] virtual auto to_string () const -> const std::string & = 0;
3738
39+ static auto from_string (std::string endpoint) -> std::shared_ptr<CppSockets::IEndpoint>;
40+ static auto from_string (std::string_view endpoint) -> std::shared_ptr<CppSockets::IEndpoint>;
41+
3842 protected:
3943 [[nodiscard]] auto make_string () const -> std::string;
4044 };
4145
4246 template <class T >
4347 class Endpoint : public IEndpoint {
4448 // TODO: Replace with new C++ requires
45- static_assert (std::is_base_of <IAddress, T>::value ,
49+ static_assert (std::is_base_of_v <IAddress, T>,
4650 " Endpoint address must derive from IAddress"
4751 );
4852 public:
4953 Endpoint (T addr, std::uint16_t port) :
5054 addr (std::move(addr)), port(port), str(make_string())
5155 {};
52- ~Endpoint () override = default ;
56+ Endpoint (const Endpoint &other) = default ;
57+ Endpoint (Endpoint &&other) noexcept = default ;
58+ ~Endpoint () override = default ;
59+
60+ auto operator =(const Endpoint &other) -> Endpoint & = default ;
61+ auto operator =(Endpoint &&other) noexcept -> Endpoint & = default ;
5362
5463 [[nodiscard]] auto get_port () const -> std::uint16_t override { return port; }
5564 [[nodiscard]] auto get_addr () const -> const T & override { return addr; }
0 commit comments