From 5e8fa708053af94ba1be44e2c4ef282aba8d105d Mon Sep 17 00:00:00 2001 From: falsycat Date: Tue, 1 Nov 2022 11:52:26 -0700 Subject: [PATCH] fix compiler errors on MSVC --- CMakeLists.txt | 1 + common/future.hh | 28 ++++++++++++++++++---------- common/luajit.cc | 2 +- common/luajit_thread.cc | 3 +-- file/audio_context.cc | 8 ++++---- file/gl_obj.cc | 2 +- file/value_plot.cc | 2 +- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96feae0..e671c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ target_include_directories(nf7 PRIVATE . "${PROJECT_BINARY_DIR}/include") target_compile_options(nf7 PRIVATE ${NF7_OPTIONS_WARNING} ${NF7_OPTIONS_SANITIZE} + $<$:/bigobj> ) target_link_options(nf7 PRIVATE ${NF7_OPTIONS_SANITIZE} diff --git a/common/future.hh b/common/future.hh index e347bb0..db10c7f 100644 --- a/common/future.hh +++ b/common/future.hh @@ -265,10 +265,12 @@ class Future final { }); return pro.future(); } - ThisFuture& Then(const std::shared_ptr& ctx, auto&& f) noexcept { + template + ThisFuture& Then(const std::shared_ptr& ctx, F&& f) noexcept { return Then(nf7::Env::kSub, ctx, std::move(f)); } - ThisFuture& Then(auto&& f) noexcept { + template + ThisFuture& Then(F&& f) noexcept { return Then(nullptr, std::move(f)); } @@ -281,10 +283,11 @@ class Future final { }); return *this; } - ThisFuture& ThenIf(const std::shared_ptr& ctx, auto&& f) noexcept { + ThisFuture& ThenIf(const std::shared_ptr& ctx, + std::function&& f) noexcept { return ThenIf(nf7::Env::kSub, ctx, std::move(f)); } - ThisFuture& ThenIf(auto&& f) noexcept { + ThisFuture& ThenIf(std::function&& f) noexcept { return ThenIf(nullptr, std::move(f)); } @@ -299,18 +302,20 @@ class Future final { return *this; } template - ThisFuture& Catch(const std::shared_ptr& ctx, auto&& f) noexcept { + ThisFuture& Catch(const std::shared_ptr& ctx, + std::function&& f) noexcept { return Catch(nf7::Env::kSub, ctx, std::move(f)); } template - ThisFuture& Catch(auto&& f) noexcept { + ThisFuture& Catch(std::function&& f) noexcept { return Catch(nullptr, std::move(f)); } // Finalizes the other promise on finalize of this future. + template ThisFuture& Chain(nf7::Env::Executor exec, const std::shared_ptr& ctx, - auto& pro, auto&& func) noexcept { + P& pro, F&& func) noexcept { return Then(exec, ctx, [pro, func = std::move(func)](auto& fu) mutable { try { if constexpr (std::is_void::value) { @@ -323,13 +328,16 @@ class Future final { } }); } - ThisFuture& Chain(const std::shared_ptr& ctx, auto& pro, auto&& func) noexcept { + template + ThisFuture& Chain(const std::shared_ptr& ctx, P& pro, F&& func) noexcept { return Chain(nf7::Env::kSub, ctx, pro, std::move(func)); } - ThisFuture& Chain(auto& pro, auto&& func) noexcept { + template + ThisFuture& Chain(P& pro, F&& func) noexcept { return Chain(nullptr, pro, std::move(func)); } - ThisFuture& Chain(auto& pro) noexcept { + template + ThisFuture& Chain(P& pro) noexcept { return Chain(pro, [](auto& v) { return v; }); } diff --git a/common/luajit.cc b/common/luajit.cc index 24f700f..c91c07e 100644 --- a/common/luajit.cc +++ b/common/luajit.cc @@ -398,7 +398,7 @@ void PushNodeRootLambda( lua_setfield(L, -2, "__index"); lua_pushcfunction(L, [](auto L) { - CheckNodeRootLambda(L, 1).~T(); + CheckNodeRootLambda(L, 1).~shared_ptr(); return 0; }); lua_setfield(L, -2, "__gc"); diff --git a/common/luajit_thread.cc b/common/luajit_thread.cc index dbbe263..c0ee2ce 100644 --- a/common/luajit_thread.cc +++ b/common/luajit_thread.cc @@ -139,8 +139,7 @@ static void PushMeta(lua_State* L) noexcept { auto fu = im->Import(*th, name); fu.ThenIf([L, th](auto& obj) { th->ExecResume(L, obj); - }). - template Catch([L, th](auto&) { + }).template Catch([L, th](auto&) { if (auto log = th->logger()) { log->Warn("import failed, returning nil"); } diff --git a/file/audio_context.cc b/file/audio_context.cc index 89d7433..442f2d3 100644 --- a/file/audio_context.cc +++ b/file/audio_context.cc @@ -178,8 +178,8 @@ void AudioContext::UpdateDeviceListMenu(ma_device_info* ptr, ma_uint32 n) noexce ImGui::Text("default: %s", ptr[i].isDefault? "yes": "no"); ImGui::TextUnformatted("native formats:"); - const auto n = std::min(ptr[i].nativeDataFormatCount, ma_uint32 {5}); - for (ma_uint32 j = 0; j < n; ++j) { + const auto fmtn = std::min(ptr[i].nativeDataFormatCount, ma_uint32 {5}); + for (ma_uint32 j = 0; j < fmtn; ++j) { const auto& d = ptr[i].nativeDataFormats[j]; const char* fmt = d.format == ma_format_u8? "u8": @@ -191,10 +191,10 @@ void AudioContext::UpdateDeviceListMenu(ma_device_info* ptr, ma_uint32 n) noexce ImGui::Bullet(); ImGui::Text("%s / %" PRIu32 " ch / %" PRIu32 " Hz", fmt, d.channels, d.sampleRate); } - if (ptr[i].nativeDataFormatCount > n) { + if (ptr[i].nativeDataFormatCount > fmtn) { ImGui::Bullet(); ImGui::TextDisabled("etc..."); } - if (n == 0) { + if (fmtn == 0) { ImGui::Bullet(); ImGui::TextDisabled("(nothing)"); } ImGui::EndTooltip(); diff --git a/file/gl_obj.cc b/file/gl_obj.cc index 1ab3b84..858f75b 100644 --- a/file/gl_obj.cc +++ b/file/gl_obj.cc @@ -983,7 +983,7 @@ struct Program { for (const auto& pa : *uni) { try { SetUniform(prog->id(), pa.first.c_str(), pa.second); - } catch (nf7::Exception& e) { + } catch (nf7::Exception&) { p.log->Warn("uniform '"+pa.first+"' is ignored"); } } diff --git a/file/value_plot.cc b/file/value_plot.cc index 839a71c..ec2177f 100644 --- a/file/value_plot.cc +++ b/file/value_plot.cc @@ -225,7 +225,7 @@ class Plot::Lambda final : public nf7::Node::Lambda { throw nf7::Exception {"expected vector"}; } } catch (nf7::ExpiredException&) { - } catch (nf7::Exception& e) { + } catch (nf7::Exception&) { f_->log_.Warn("plotter error"); }