header_utils
Loading...
Searching...
No Matches
with_sl.h
1
4
5#pragma once
6
7#include "min-cpp-version/cpp20.h"
8#include <concepts>
9#include "source_location.h"
10#include "hashes.h"
11
12#ifdef __INTELLISENSE__
13#define EQ_SOURCE_LOCATION = source_location{}
14#else
15#define EQ_SOURCE_LOCATION = source_location::current()
16#endif
17
18namespace ghassanpl
19{
20
34
36 template <typename T>
37 struct with_sl
38 {
39 T Object;
40 source_location Location;
41
42 template <typename U>
43 requires (!std::same_as<std::remove_cvref_t<U>, with_sl<T>>)
44 with_sl(U&& u, source_location loc EQ_SOURCE_LOCATION)
45 : Object(std::forward<U>(u)), Location(std::move(loc))
46 {
47 }
48
49 with_sl(with_sl const& other) noexcept = default;
50 with_sl(with_sl&& other) noexcept = default;
51 with_sl& operator=(with_sl const& other) noexcept = default;
52 with_sl& operator=(with_sl&& other) noexcept = default;
53 };
54
57 template <typename T, typename HASH_FUNC = crc64_hasher>
58 struct with_slh
59 {
60 using hash_func = HASH_FUNC;
61 using hash_type = decltype(HASH_FUNC{}(source_location{}));
62
63 T Object;
64 hash_type LocationHash;
65
66 template <typename U>
67 requires (!std::same_as<std::remove_cvref_t<U>, with_slh<T>>)
68#ifdef __INTELLISENSE__
69 with_slh(U&& t, hash_type loc = {})
70#else
71 with_slh(U&& t, hash_type loc = HASH_FUNC{}(source_location::current()))
72#endif
73 : Object(std::forward<U>(t)), LocationHash(loc)
74 {
75 }
76
77 with_slh(with_slh const& other) noexcept = default;
78 with_slh(with_slh&& other) noexcept = default;
79 with_slh& operator=(with_slh const& other) noexcept = default;
80 with_slh& operator=(with_slh&& other) noexcept = default;
81 };
82
84}
Primary namespace for everything in this library.
Definition align+rec2.h:10