-
-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Here is my code
#include <concepts>
auto foo(auto x)
{
if constexpr (std::same_as<int, decltype(x)>)
{
return 1;
}
return 2;
}
int main()
{
foo(1);
foo(1.0);
}Here is the C++ Insights translation
#include <concepts>
auto foo(auto x)
{
if constexpr (std::same_as<int, decltype(x)>)
{
return 1;
}
return 2;
}
#ifdef INSIGHTS_USE_TEMPLATE
template<>
int foo<int>(int x)
{
if constexpr(std::same_as<int, int>) {
return 1;
}
return 2;
}
#endif
#ifdef INSIGHTS_USE_TEMPLATE
template<>
int foo<double>(double x)
{
if constexpr(std::same_as<int, double>) {
}
return 2;
}
#endif
int main()
{
foo(1);
foo(1.0);
}
Why
if constexpr(std::same_as<int, int>) {
return 1;
} But
if constexpr(std::same_as<int, double>) {
} If C++ Insights doesn't expand constexpr expressions into their values, then why does the second option look so strange?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working