Skip to content

Commit 6541226

Browse files
committed
Make observer_ptr constructor explicit
1 parent b90a111 commit 6541226

6 files changed

Lines changed: 8 additions & 8 deletions

File tree

include/luxrays/utils/observer_ptr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ class observer_ptr {
6161
"Template parameter T cannot be void"
6262
);
6363
public:
64-
using element_type = std::remove_extent_t<T>;
64+
using element_type = std::remove_extent_t<T>;
6565

6666
// Default constructor: initialize to nullptr
6767
constexpr observer_ptr() noexcept : ptr(nullptr) {}
6868
constexpr observer_ptr(std::nullptr_t) noexcept : ptr(nullptr) {}
6969

7070
// Constructor from raw pointer (implicit conversions allowed)
71-
constexpr observer_ptr(T* p) noexcept : ptr(p) {}
71+
constexpr explicit observer_ptr(T* p) noexcept : ptr(p) {}
7272

7373
// Copy constructor and assignment
7474
constexpr observer_ptr(const observer_ptr&) noexcept = default;

include/slg/lights/lightsourcedefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class LightSourceDefinitions {
7575

7676
LightSourceRef GetLightSource(size_t n) const { return lights[n]; }
7777
LightSourcePtr GetLightSourcePtr(size_t n) const {
78-
return std::addressof(lights[n].get());
78+
return LightSourcePtr(std::addressof(lights[n].get()));
7979
}
8080

8181
auto ViewEnvLightSources() {

src/slg/engines/pathocl/pathoclnativethread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ FilmPtr PathOCLNativeRenderThread::GetThreadFilmPtr() {
8989
auto * thread0 = static_cast<PathOCLNativeRenderThread *>(
9090
engine->renderNativeThreads[0]
9191
);
92-
return thread0->threadFilm.get();
92+
return FilmPtr(thread0->threadFilm.get());
9393
}
9494

9595
FilmRef PathOCLNativeRenderThread::GetThreadFilm() {

src/slg/engines/tilepathcpu/tilepathcputhread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void TilePathCPURenderThread::RenderFunc(std::stop_token stop_token) {
108108
// Render the tile
109109
//----------------------------------------------------------------------
110110

111-
sampler.Init(&tileWork, tileFilm.get());
111+
sampler.Init(&tileWork, FilmPtr(tileFilm.get()));
112112

113113
for (u_int y = 0; y < tileWork.GetCoord().height && !interruptionRequested; ++y) {
114114
for (u_int x = 0; x < tileWork.GetCoord().width && !interruptionRequested; ++x) {

src/slg/lights/lightsourcedefs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ LightSourceConstPtr LightSourceDefinitions::GetLightSourcePtr(const string &name
101101
if (e == lightsByName.end())
102102
throw runtime_error("Reference to an undefined LightSource in LightSourceDefinitions::GetLightSource(): " + name);
103103

104-
return e->second.get();
104+
return LightSourceConstPtr(e->second.get());
105105
}
106106

107107
LightSourcePtr LightSourceDefinitions::GetLightSourcePtr(const string &name) {
@@ -111,7 +111,7 @@ LightSourcePtr LightSourceDefinitions::GetLightSourcePtr(const string &name) {
111111
if (e == lightsByName.end())
112112
throw runtime_error("Reference to an undefined LightSource in LightSourceDefinitions::GetLightSource(): " + name);
113113

114-
return e->second.get();
114+
return LightSourcePtr(e->second.get());
115115
}
116116

117117
TriangleLightConstRef LightSourceDefinitions::GetLightSourceByMeshAndTriIndex(const u_int meshIndex, const u_int triIndex) const {

src/slg/lights/strategies/distributionlightstrategy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ LightSourcePtr DistributionLightStrategy::SampleLights(
6060
assert ((lightIndex >= 0) && (lightIndex < scene.GetLightSources().GetSize()));
6161

6262
if (*pdf > 0.f)
63-
return &scene.GetLightSources().GetLightSource(lightIndex);
63+
return LightSourcePtr(&scene.GetLightSources().GetLightSource(lightIndex));
6464
else
6565
return nullptr;
6666
} else

0 commit comments

Comments
 (0)