Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support object_cast_nothrow with std::optional #28

Open
KevinW1998 opened this issue Mar 10, 2017 · 3 comments
Open

Support object_cast_nothrow with std::optional #28

KevinW1998 opened this issue Mar 10, 2017 · 3 comments

Comments

@KevinW1998
Copy link

Now that C++17 nearly finished, we could use std::opational for luabind::object_cast_nothrow

@decimad
Copy link
Owner

decimad commented May 6, 2017

I don't feel comfortable adopting the standard before it is signed, although I was really expecting optional myself eagerly :(

@Wohlstand
Copy link

Wohlstand commented Jul 7, 2017

You can use macros to detect c++ standard and disable features aren't supported for older/newer standards

__cplusplus

    This macro is defined when the C++ compiler is in use. You can use __cplusplus to test whether a header is compiled by a C compiler or a C++ compiler. This macro is similar to __STDC_VERSION__, in that it expands to a version number. Depending on the language standard selected, the value of the macro is 199711L for the 1998 C++ standard, 201103L for the 2011 C++ standard, 201402L for the 2014 C++ standard, or an unspecified value strictly larger than 201402L for the experimental languages enabled by -std=c++1z and -std=gnu++1z. 

@ltjax
Copy link

ltjax commented Aug 26, 2017

You should already be able to use it with std::optional like this:
auto thisIsAnOptional = object_cast_nothrow<YourCppType>(yourLuaValue, std::optional<YourCppType>());

At least that was my plan when changing it to the way it is now. If that doesn't work, we should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants