refactor: adopt layered C++ project layout
This commit is contained in:
20
src/app/main.cpp
Normal file
20
src/app/main.cpp
Normal 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;
|
||||
}
|
21
src/lib/sample_library.cpp
Normal file
21
src/lib/sample_library.cpp
Normal 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
|
14
src/main.cpp
14
src/main.cpp
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user