Consider these two approaches that can represent an \"optional int\":
using std_optional_int = std::optional;
using my_optional_int =
libstdc++ apparently does not implement P0602 "variant and optional should propagate copy/move triviality". You can verify this with:
static_assert(std::is_trivially_copyable_v>);
which fails for libstdc++, and passes for libc++ and the MSVC standard library (which really needs a proper name so we don't have to call it either "The MSVC implementation of the C++ standard library" or "The MSVC STL").
Of course MSVC still won't pass an optional in a register because the MS ABI.
EDIT: This issue has been fixed in the GCC 8 release series.