Implement modules support#15
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
| #include <optional> | ||
| #include <ranges> | ||
| #include <type_traits> | ||
| #include <utility> |
There was a problem hiding this comment.
Putting standard library includes in the global module fragment is not the approved modules mechanism for this project. To merge this, you'll need to figure out how to get import std building. The best approach would be to do so by building with a supported container or with beman-local-ci.
There was a problem hiding this comment.
I solved it in yesmanchyk@f196c4b. However, the line 7 looks like a hack to me even though CI is passing. Maybe it's worth restoring the global module fragment with a single #include <version> inside? I don't know a way to export library feature-test macros with import std;.
There was a problem hiding this comment.
One way is import <version>, but I'm not sure header units are an approved mechanism, nor am I sure all targets support header units well enough...
As mentioned below, it seems that #include <version> (and things like <cstdarg>, <cassert>) is now allowed as a special exception in the GMF.
This reverts commit a18042b.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
ednolan
left a comment
There was a problem hiding this comment.
Great work! Just a few more small comments. By the way, you can use pre-commit run --all-files as a convenient way to apply clang-tidy and ensure that the lint check passes.
|
|
||
| import std; | ||
|
|
||
| using size_t = std::size_t; |
There was a problem hiding this comment.
Instead of doing this, change all the instances of non-namespaced size_t to std::size_t.
|
|
||
| using size_t = std::size_t; | ||
|
|
||
| #define __cpp_lib_ranges 202207L |
There was a problem hiding this comment.
Sorry, I should have mentioned, but if a C++ standard library header just defines macros, you can put it in the global module fragment, so <version> is fine here, as is <cassert>
| #include <gtest/gtest.h> | ||
| #if BEMAN_SCAN_VIEW_USE_MODULES() | ||
|
|
||
| #include <gtest/gtest.h> |
There was a problem hiding this comment.
You're including <gtest/gtest.h> in both branches, so just move it to before the #if BEMAN_SCAN_VIEW_USE_MODULES().
Mick235711
left a comment
There was a problem hiding this comment.
Thanks a lot for working on this!
There was a problem hiding this comment.
Should this file be committed? If it is just an temporary intermediate file, please put it in .gitignore.
|
|
||
| #else | ||
|
|
||
| #if !BEMAN_SCAN_VIEW_USE_MODULES() |
There was a problem hiding this comment.
I think we should probably use #elif here
| option( | ||
| BEMAN_SCAN_VIEW_USE_MODULES | ||
| "Provide beman.scan_view as a C++ module" | ||
| OFF | ||
| ) |
There was a problem hiding this comment.
Maybe we should mention this new flag somewhere in README (or CONTRIBUTING.md)?
This implementation is based on bemanproject/exemplar#380
There are some key differences, however:
I useimport beman.scan_view;instead of#include <beman/scan_view/scan.hpp>in tests and examples.import std;resulted in compilation errors when I tried gcc 16 and clang 21.Due to above 2 reasons I extracted thebeman::scan_viewimplementation intoscan_view.hppwithout any changes.