-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
[BUG] Code Example Doesn't Compile #524
Comments
Hello @codereport, thanks for raising this issue. The short answer is that C++ Insights still uses Clang 15, which does not support ranges (at least to my knowledge). I created an issue for the Clang update, #525. The longer answer is it's more complicated. In the link you provided, Clang is used with libstdc++ (from GCC) because that's the default under Linux. You can switch the lib under "More Transformation" (maybe not the best heading). Once C++ Insights uses Clang 16, that would work. I don't know why Clang doesn't seem to play well with libstdc++ regarding ranges. Even with Clang 16, I believe you will not see what you are looking for because C++ Insights does only expand statements from the current source file. #428 provides an explanation. I can still imagine supporting this, but I assume that the resulting code could be a lot to process. I used an experimental version and... well... a lot of code was produced. The following is the transformation result from my local C++ Insights version using Clang 16 (without the additional patch to dive into headers): include <vector>
#include <ranges>
std::ranges::transform_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > >, __lambda_7_40> plus_one(std::vector<int, std::allocator<int> > && vec)
{
class __lambda_7_40
{
public:
template<class type_parameter_0_0>
inline /*constexpr */ auto operator()(type_parameter_0_0 e) const
{
return e + 1;
}
#ifdef INSIGHTS_USE_TEMPLATE
template<>
inline /*constexpr */ int operator()<int>(int e) const
{
return e + 1;
}
#endif
private:
template<class type_parameter_0_0>
static inline /*constexpr */ auto __invoke(type_parameter_0_0 e)
{
return __lambda_7_40{}.operator()<type_parameter_0_0>(e);
}
public:
// inline /*constexpr */ __lambda_7_40() noexcept = default;
// inline /*constexpr */ __lambda_7_40(__lambda_7_40 &&) noexcept = default;
// /*constexpr */ __lambda_7_40() = default;
} __lambda_7_40{};
return operator|(vec, std::ranges::views::transform.operator()(__lambda_7_40));
}
int main()
{
plus_one(std::vector<int, std::allocator<int> >{std::initializer_list<int>{1, 2, 3}});
return 0;
} Andreas |
Fixed by #569. |
The following code example doesn't compile:
CppInsights Link: https://cppinsights.io/s/9b7c139b
The equivalent code on Godbolt does. I am not sure what is causing the issue but seems like it should work. Here is a twitter link with some discussion as well: https://twitter.com/code_report/status/1646638445555761152?s=20
The text was updated successfully, but these errors were encountered: