C++20 concepts are not being removed
konakarthik12 opened this issue · comments
Declarations of concepts, a feature introduced in C++ 20, are not being removed.
In the example below, the Printable
concept is unused and should be removed.
input.cpp:
#include <iostream>
#include <concepts>
template<typename T>
concept Addable = requires(T a, T b) {
{a + b} -> std::same_as<T>;
};
template<typename T>
concept Printable = requires(T t) { // this concept is unused but it is not removed
{std::cout << t};
};
template<Addable T>
T add(T a, T b) {
return a + b;
}
int main() {
std::cout << add(5, 3) << std::endl;
std::cout << add(2.5, 3.7) << std::endl;
return 0;
}
result.cpp (identical to input):
#include <iostream>
#include <concepts>
template<typename T>
concept Addable = requires(T a, T b) {
{a + b} -> std::same_as<T>;
};
template<typename T>
concept Printable = requires(T t) { // this concept is unused but it is not removed
{std::cout << t};
};
template<Addable T>
T add(T a, T b) {
return a + b;
}
int main() {
std::cout << add(5, 3) << std::endl;
std::cout << add(2.5, 3.7) << std::endl;
return 0;
}