Skip to content
Open
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e85418b
issue-2282: PL changes
shewitt-au May 31, 2025
bbace8d
Remove debugging code
shewitt-au May 31, 2025
9d63054
Hard to get every one. time...
shewitt-au May 31, 2025
db3c947
Hard to get every one
shewitt-au May 31, 2025
1b5c8f6
WIP
shewitt-au Jun 1, 2025
e1b869d
WIP
shewitt-au Jun 1, 2025
fdf3df4
WIP
shewitt-au Jun 1, 2025
ad24e44
WIP
shewitt-au Jun 1, 2025
c004860
WIP
shewitt-au Jun 1, 2025
b2606d8
WIP
shewitt-au Jun 1, 2025
1214cd8
WIP
shewitt-au Jun 1, 2025
4295ce6
WIP
shewitt-au Jun 1, 2025
5e0b38b
WIP
shewitt-au Jun 1, 2025
ab9a3a9
WIP
shewitt-au Jun 1, 2025
f7d6fc0
WIP
shewitt-au Jun 1, 2025
2ac6ba9
WIP
shewitt-au Jun 1, 2025
c5496e1
WIP
shewitt-au Jun 1, 2025
29be2d2
WIP
shewitt-au Jun 2, 2025
4e07ab2
Taking a slightly different approach
shewitt-au Jun 2, 2025
8ea5dc4
Add 'construct_shared_object.hpp'
shewitt-au Jun 2, 2025
324a136
WIP
shewitt-au Jun 2, 2025
3ec6ae2
WIP
shewitt-au Jun 2, 2025
9489b3c
It builds
shewitt-au Jun 2, 2025
c6095e6
Change comment
shewitt-au Jun 2, 2025
830d0ee
fix: post_construct not being called on some compilers
shewitt-au Jun 3, 2025
ce784c4
Attempt and strange problem casuing build isssues
shewitt-au Jun 3, 2025
32037d1
Attempt and strange problem casuing build isssues
shewitt-au Jun 3, 2025
8a008a2
Attempt and strange problem casuing build isssues
shewitt-au Jun 3, 2025
7c0884b
Replace more make_shared calls
shewitt-au Jun 3, 2025
a47cc5f
Work on unit tests
shewitt-au Jun 3, 2025
e1fd97a
Work on unit tests
shewitt-au Jun 3, 2025
b17db3f
Work on unit tests
shewitt-au Jun 3, 2025
093a4e1
Work on unit tests
shewitt-au Jun 3, 2025
c40fbe3
Work on unit tests
shewitt-au Jun 3, 2025
ab43e67
Work on unit tests
shewitt-au Jun 3, 2025
bb5bc62
Work on unit tests
shewitt-au Jun 3, 2025
36deb13
Fixing tests
shewitt-au Jun 4, 2025
3eb2833
Fixing tests
shewitt-au Jun 4, 2025
cab951b
Fixing tests
shewitt-au Jun 4, 2025
8e82fdd
Fixing tests
shewitt-au Jun 4, 2025
6173dfc
Fixing tests
shewitt-au Jun 4, 2025
21fa172
Make all patterns I could find have protected constructors
shewitt-au Jun 4, 2025
3291051
Change static cast to dynamic
shewitt-au Jun 5, 2025
29b7486
Moved friend declations to end of class
shewitt-au Jun 5, 2025
c308e82
New allocation method (WIP)
shewitt-au Jun 6, 2025
1fd2401
It's looking like it may actually buid. We'll soon know
shewitt-au Jun 6, 2025
e380aeb
Last claims premature
shewitt-au Jun 6, 2025
aaae498
Move stuff around
shewitt-au Jun 6, 2025
9694a1c
New allocation method. Other small changes
shewitt-au Jun 7, 2025
13ec0b8
Renamed some stuff
shewitt-au Jun 8, 2025
cbd3f62
Renamed some stuff
shewitt-au Jun 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
It's looking like it may actually buid. We'll soon know
  • Loading branch information
shewitt-au committed Jun 6, 2025
commit 1fd24010149e560ff3c6236485c685188c30e636
33 changes: 18 additions & 15 deletions lib/include/pl/helpers/construct_shared_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,19 @@ instantiation.
#include <memory>
#include <utility>

#define BEFRIEND_CONSTRUCT_SHARED_OBJECT(T) friend struct safe_enable_shared_from_this::Allocator<T>;

namespace shared_object_creator {

/*
safe_enable_shared_from_this was found here:
https://stackoverflow.com/questions/8147027/how-do-i-call-stdmake-shared-on-a-class-with-only-protected-or-private-const

Posted by stackoverflow member Carsten.
He adapted old code from stackoverflow member Zsolt Rizsányi,
who in turn says it was invented by Jonathan Wakely (GCC developer).
// safe_enable_shared_from_this was found here:
// https://stackoverflow.com/questions/8147027/how-do-i-call-stdmake-shared-on-a-class-with-only-protected-or-private-const
//
// Posted by stackoverflow member Carsten.
// He adapted old code from stackoverflow member Zsolt Rizsányi,
// who in turn says it was invented by Jonathan Wakely (GCC developer).
//
// The only modification I have made is to enable copy-construction.
//
// C++23

The only modification I have made is to enable copy-construction.

C++23
*/
class safe_enable_shared_from_this : public std::enable_shared_from_this<safe_enable_shared_from_this> {
protected:
safe_enable_shared_from_this() noexcept = default;
Expand All @@ -74,10 +71,11 @@ class safe_enable_shared_from_this : public std::enable_shared_from_this<safe_en

public:
template <typename T, typename... TArgs>
static inline auto create(TArgs&&... args) -> ::std::shared_ptr<T> {
static inline auto create(TArgs&&... args) -> std::shared_ptr<T> {
return std::allocate_shared<T>(Allocator<T>{}, std::forward<TArgs>(args)...);
}

public:
template <typename TSelf>
auto inline shared_from_this(this TSelf&& self) noexcept
{
Expand All @@ -98,7 +96,7 @@ class safe_enable_shared_from_this : public std::enable_shared_from_this<safe_en
template<typename T, typename... Args>
requires requires(T t, Args&&... args) {
t.post_construct(std::forward<Args>(args)...);
}
}
std::shared_ptr<T> construct_shared_object(Args&&... args) {
auto p = safe_enable_shared_from_this::create<T>(std::forward<Args>(args)...);
p->post_construct(std::forward<Args>(args)...);
Expand All @@ -111,3 +109,8 @@ std::shared_ptr<T> construct_shared_object(Args&&... args) {
}

} // namespace shared_object_creator

#define BEFRIEND_CONSTRUCT_SHARED_OBJECT(T) \
friend struct shared_object_creator::safe_enable_shared_from_this::Allocator<T>; \
template<typename T, typename... Args> \
friend std::shared_ptr<T> shared_object_creator::construct_shared_object(Args&&... args);