Transform a C++ program consisting of multiple source files and headers into a single self-contained source file without any external dependencies (except for standard system headers). Unused code is not included in the resulting file.
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;
}
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:
result.cpp (identical to input):