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

chore: Mark detail:forward_like as constexpr #4147

Merged

Conversation

Skylion007
Copy link
Collaborator

Description

Well looking into the new std::forward_like, I realized our detail:forward_like should also be constexpr at the very least. This is a small change and seems to work on C++11.

Suggested changelog entry:

* Mark detail::forward_like as constexpr

Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Your "ifdef using std::forward_like" question is a good one. Something to keep in mind as soon as we get our hands on a C++23 compiler.

@Skylion007 Skylion007 marked this pull request as ready for review August 20, 2022 21:04
@Skylion007 Skylion007 merged commit 81f35d2 into pybind:master Aug 20, 2022
@Skylion007 Skylion007 deleted the skylion007/constexpr-detail-forward-like branch August 20, 2022 21:05
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Aug 20, 2022
@rwgk
Copy link
Collaborator

rwgk commented Aug 22, 2022

Thanks! Your "ifdef using std::forward_like" question is a good one. Something to keep in mind as soon as we get our hands on a C++23 compiler.

FYI, apparently even clang 15 dev doesn't (yet?) support it (silkeh/clang:dev):

#include <iostream>
#include <utility>

int main() {
#if !defined(__cpp_lib_forward_like)
  std::cout << "NOT ";
#endif
  std::cout << "defined(__cpp_lib_forward_like)" << std::endl;
  return 0;
}
root@9e4ec44470bc:/# clang++ --version
Debian clang version 15.0.0-++20220719071818+5fc621355110-1~exp1~20220719071918.324
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
root@9e4ec44470bc:/# clang++ -std=c++2b std_forward_like.cc && ./a.out
NOT defined(__cpp_lib_forward_like)
root@9e4ec44470bc:/# clang++ -std=c++23 std_forward_like.cc && ./a.out
error: invalid value 'c++23' in '-std=c++23'
note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU extensions' standard
note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard
note: use 'c++20' for 'ISO C++ 2020 DIS' standard
note: use 'gnu++20' for 'ISO C++ 2020 DIS with GNU extensions' standard
note: use 'c++2b' for 'Working draft for ISO C++ 2023 DIS' standard
note: use 'gnu++2b' for 'Working draft for ISO C++ 2023 DIS with GNU extensions' standard

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

Successfully merging this pull request may close these issues.

3 participants