le2d v0.4.7
2D game engine framework
 
Loading...
Searching...
No Matches
uri.hpp
Go to the documentation of this file.
1#pragma once
2#include <string>
3
4namespace le {
5class Uri {
6 public:
7 struct Hasher;
8
9 Uri() = default;
10
11 template <std::convertible_to<std::string> Type>
12 /*implicit*/ Uri(Type t) : m_str(std::move(t)), m_hash(std::hash<std::string>{}(m_str)) {}
13
14 [[nodiscard]] auto get_string() const -> std::string_view { return m_str; }
15 [[nodiscard]] auto get_hash() const -> std::size_t { return m_hash; }
16
17 auto operator==(Uri const& rhs) const -> bool { return m_hash == rhs.m_hash; }
18
19 private:
20 std::string m_str{};
21 std::size_t m_hash{};
22};
23
25 [[nodiscard]] auto operator()(Uri const& uri) const -> std::size_t { return uri.get_hash(); }
26};
27} // namespace le
Definition uri.hpp:5
auto get_string() const -> std::string_view
Definition uri.hpp:14
Uri()=default
auto operator==(Uri const &rhs) const -> bool
Definition uri.hpp:17
Uri(Type t)
Definition uri.hpp:12
auto get_hash() const -> std::size_t
Definition uri.hpp:15
Definition animation.hpp:8
Definition uri.hpp:24
auto operator()(Uri const &uri) const -> std::size_t
Definition uri.hpp:25