On 16.06.2025 21:50, Marcel Mueller wrote:
Maybe a move constructor w/o noexcept should be a warning, because it
makes no much sense to throw within a move operation.
It is a warning C26439 in VS2022, albeit you need to call the special
code analysis step instead of standard code compilation.
Analyze: Run Code analysis
Build started at 08:43...
------ Build started: Project: ConsoleTest2022, Configuration: Debug
x64 ------
main.cpp
C:\Test\ConsoleTestVS2022\ConsoleTest2022\main.cpp(6,7): warning
C4625: 'bar': copy constructor was implicitly defined as deleted 1>C:\Test\ConsoleTestVS2022\ConsoleTest2022\main.cpp(6,7): warning
C4626: 'bar': assignment operator was implicitly defined as deleted C:\Test\ConsoleTestVS2022\ConsoleTest2022\main.cpp(9): warning C26439:
This kind of function should not throw. Declare it 'noexcept' (f.6).
Done building project "ConsoleTest2022.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== ========== Build completed at 08:43 and took 01,440 seconds ==========
#include <iostream>
#include <string>
#include <vector>
class bar {
public:
bar() = default;
bar(bar&& b): s_(std::move(b.s_)) {}
private:
std::string s_;
};
int main() {
std::vector<bar> bars;
bars.push_back(bar());
}
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)