Skip to content

Commit 68e7815

Browse files
committed
Migrate to C++20
1 parent 172eb2c commit 68e7815

File tree

26 files changed

+109
-108
lines changed

26 files changed

+109
-108
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_policy(SET CMP0091 NEW)
33

44
project(Framework CXX)
55

6-
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD 20)
77
set(CMAKE_CXX_STANDARD_REQUIRED ON)
88
set(FW_STANDALONE true)
99

cmake/FrameworkSetup.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(CMAKE_CXX_STANDARD 17)
1+
set(CMAKE_CXX_STANDARD 20)
22
set(CMAKE_CXX_STANDARD_REQUIRED ON)
33
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
44
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
@@ -30,5 +30,5 @@ if(UNIX OR APPLE)
3030
-Wno-invalid-offsetof
3131
)
3232
add_compile_options(${DISABLED_WARNS})
33-
set(CMAKE_CXX_FLAGS "-std=c++20 ${CMAKE_CXX_FLAGS}")
33+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
3434
endif()

code/framework/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ target_compile_definitions(FrameworkNodeEngine PRIVATE NODE_WANT_INTERNALS=1)
233233

234234
# Match Framework compile definitions and features
235235
target_compile_definitions(FrameworkNodeEngine PRIVATE MG_ENABLE_LOG=0)
236-
target_compile_features(FrameworkNodeEngine PRIVATE cxx_std_17)
236+
target_compile_features(FrameworkNodeEngine PRIVATE cxx_std_20)
237237

238238
# Link the solutions based on the platform
239239
link_shared_deps(Framework)

code/framework/src/external/imgui/wrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ namespace Framework::External::ImGUI {
100100
}
101101

102102
Error Wrapper::Update() {
103-
std::lock_guard _lock(_renderMtx);
103+
std::scoped_lock _lock(_renderMtx);
104104

105105
switch (_config.renderBackend) {
106106
case Graphics::RendererBackend::BACKEND_D3D_9: {
@@ -135,7 +135,7 @@ namespace Framework::External::ImGUI {
135135
}
136136

137137
Error Wrapper::Render() {
138-
std::lock_guard _lock(_renderMtx);
138+
std::scoped_lock _lock(_renderMtx);
139139

140140
if (!isContextInitialized) {
141141
return Error::IMGUI_NOT_INITIALIZED;

code/framework/src/graphics/backend/d3d11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ namespace Framework::Graphics {
337337
void D3D11Backend::CreateGeometry(uint32_t geometry_id, const VertexBuffer &vertices, const IndexBuffer &indices) {
338338
BindVertexLayout(vertices.format);
339339

340-
if (_geometry.find(geometry_id) != _geometry.end())
340+
if (_geometry.contains(geometry_id))
341341
return;
342342

343343
GeometryEntry geometry;

code/framework/src/gui/backend/view_d3d11.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ namespace Framework::GUI {
149149
return;
150150
}
151151

152-
std::lock_guard lock(_renderMutex);
152+
std::scoped_lock lock(_renderMutex);
153153

154154
// Update the view content
155155
View::Update();
@@ -160,7 +160,7 @@ namespace Framework::GUI {
160160
return;
161161
}
162162

163-
std::lock_guard lock(_renderMutex);
163+
std::scoped_lock lock(_renderMutex);
164164

165165
// Update D3D11 internal resources
166166
UpdateGeometry();

code/framework/src/gui/manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace Framework::GUI {
7070
}
7171

7272
// Update the renderer
73-
std::lock_guard lock(_renderMutex);
73+
std::scoped_lock lock(_renderMutex);
7474
_ultralightRenderer->Update();
7575
_ultralightRenderer->RefreshDisplay(0);
7676
_ultralightRenderer->Render();
@@ -95,7 +95,7 @@ namespace Framework::GUI {
9595
return a->GetZIndex() < b->GetZIndex();
9696
});
9797

98-
std::lock_guard lock(_renderMutex);
98+
std::scoped_lock lock(_renderMutex);
9999

100100
// Render the views
101101
for (auto &view : views) {

code/framework/src/gui/sdk.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace Framework::GUI {
4545

4646
inline void RemoveEventListener(std::string eventName) {
4747
// Make sure the event exist
48-
if (_eventListeners.find(eventName) == _eventListeners.end()) {
48+
if (!_eventListeners.contains(eventName)) {
4949
return;
5050
}
5151

@@ -55,7 +55,7 @@ namespace Framework::GUI {
5555

5656
inline void BroadcastEvent(std::string eventName, std::string eventPayload) {
5757
// Make sure the event exist
58-
if (_eventListeners.find(eventName) == _eventListeners.end()) {
58+
if (!_eventListeners.contains(eventName)) {
5959
return;
6060
}
6161

code/framework/src/gui/view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace Framework::GUI {
5959
return;
6060
}
6161

62-
std::lock_guard lock(_renderMutex);
62+
std::scoped_lock lock(_renderMutex);
6363

6464
// Update the view content (CPU renderer)
6565
if (!_gpuAccelerated) {

code/framework/src/jobs/io_tasks.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace Framework::Jobs::IO {
142142

143143
bool allDone = false;
144144
{
145-
std::lock_guard<std::mutex> lock(state->mutex);
145+
std::scoped_lock lock(state->mutex);
146146
state->results[i] = std::move(result);
147147
state->completed++;
148148
allDone = (state->completed == state->total);
@@ -194,7 +194,7 @@ namespace Framework::Jobs::IO {
194194
result.success = false;
195195
}
196196

197-
std::lock_guard<std::mutex> lock(resultsMutex);
197+
std::scoped_lock lock(resultsMutex);
198198
results[i] = std::move(result);
199199
});
200200
}

0 commit comments

Comments
 (0)