mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 21:59:54 -06:00
TryCompileCode(): Prevent warning on return value
Some newer compilers warn in situations where the returned local variable could be movable, but a C++11 defect meant older compilers may still return a copy when a type conversion is involved. Adding the suggested std::move prevents that warning on that compiler, but creates a new warning on others. Constructing the actual return type explicitly with the suggested std::move on the constructor argument keeps both sets of compilers happy.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <cm/string_view>
|
||||
@@ -1131,7 +1132,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
||||
result.VariableCached = !arguments.NoCache;
|
||||
result.Output = std::move(output);
|
||||
result.ExitCode = res;
|
||||
return result;
|
||||
return cm::optional<cmTryCompileResult>(std::move(result));
|
||||
}
|
||||
|
||||
bool cmCoreTryCompile::IsTemporary(std::string const& path)
|
||||
|
||||
Reference in New Issue
Block a user