-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a cmake check whether std::expected is supported or not
Note. Perhaps a wrong way. Please let me know if there is something better.
- Loading branch information
Showing
4 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": 3, | ||
"version": 6, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 17, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function(has_expected OUT_RESULT) | ||
try_compile(COMPILE_RESULT | ||
${CMAKE_BINARY_DIR}/test_apps | ||
${CMAKE_SOURCE_DIR}/cmake/try-compile-apps/expected.cpp | ||
CXX_STANDARD 23 | ||
CXX_STANDARD_REQUIRED TRUE | ||
CXX_EXTENSIONS FALSE | ||
) | ||
set(${OUT_RESULT} ${COMPILE_RESULT} PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <expected> | ||
#include <string> | ||
|
||
int main(int /*argc*/, char* /*argv*/[]) | ||
{ | ||
using Expected = std::expected<int, std::string>; | ||
|
||
Expected result{0}; | ||
Expected unxepectedResult = std::unexpected(std::string{"foo"}); | ||
|
||
return result != unxepectedResult ? *result : -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters