refactor: adopt layered C++ project layout

This commit is contained in:
2025-09-23 14:03:16 +08:00
parent b5ccc595e0
commit b74681a0f5
6 changed files with 95 additions and 27 deletions

20
src/app/main.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include <project/sample_library.hpp>
#include <iostream>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
const project::Greeter greeter{"Welcome"};
std::cout << greeter.greet("Coding World") << '\n';
auto sequence = project::generate_sequence(5);
std::cout << "Sample sequence:";
for (int value : sequence) {
std::cout << ' ' << value;
}
std::cout << '\n';
return 0;
}

View File

@@ -0,0 +1,21 @@
#include <project/sample_library.hpp>
#include <numeric>
namespace project {
std::string Greeter::greet(const std::string &name) const {
return base_message_ + ", " + name + "!";
}
std::vector<int> generate_sequence(int limit) {
if (limit < 0) {
limit = 0;
}
std::vector<int> result(static_cast<std::size_t>(limit));
std::iota(result.begin(), result.end(), 0);
return result;
}
} // namespace project

View File

@@ -1,14 +0,0 @@
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
// TODO: Add program logic here.
return 0;
}