|
4 | 4 | ** Author Francois Michaut |
5 | 5 | ** |
6 | 6 | ** 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 Fri Jun 12 03:54:40 2026 Francois Michaut |
8 | 8 | ** |
9 | 9 | ** Address.hpp : Interface to represent network addresses |
10 | 10 | */ |
@@ -35,21 +35,29 @@ namespace CppSockets { |
35 | 35 | [[nodiscard]] virtual auto get_addr() const -> const IAddress & = 0; |
36 | 36 | [[nodiscard]] virtual auto to_string() const -> const std::string & = 0; |
37 | 37 |
|
| 38 | + static auto from_string(std::string endpoint) -> std::shared_ptr<CppSockets::IEndpoint>; |
| 39 | + static auto from_string(std::string_view endpoint) -> std::shared_ptr<CppSockets::IEndpoint>; |
| 40 | + |
38 | 41 | protected: |
39 | 42 | [[nodiscard]] auto make_string() const -> std::string; |
40 | 43 | }; |
41 | 44 |
|
42 | 45 | template <class T> |
43 | 46 | class Endpoint : public IEndpoint { |
44 | 47 | // TODO: Replace with new C++ requires |
45 | | - static_assert(std::is_base_of<IAddress, T>::value, |
| 48 | + static_assert(std::is_base_of_v<IAddress, T>, |
46 | 49 | "Endpoint address must derive from IAddress" |
47 | 50 | ); |
48 | 51 | public: |
49 | 52 | Endpoint(T addr, std::uint16_t port) : |
50 | 53 | addr(std::move(addr)), port(port), str(make_string()) |
51 | 54 | {}; |
52 | | - ~Endpoint() override = default; |
| 55 | + Endpoint(const Endpoint &other) = default; |
| 56 | + Endpoint(Endpoint &&other) noexcept = default; |
| 57 | + ~Endpoint() override = default; |
| 58 | + |
| 59 | + auto operator=(const Endpoint &other) -> Endpoint & = default; |
| 60 | + auto operator=(Endpoint &&other) noexcept -> Endpoint & = default; |
53 | 61 |
|
54 | 62 | [[nodiscard]] auto get_port() const -> std::uint16_t override { return port; } |
55 | 63 | [[nodiscard]] auto get_addr() const -> const T & override { return addr; } |
|
0 commit comments