Add VSCode configuration files for debugging and building with CMake; refactor main.cpp to clean up includes
This commit is contained in:
parent
c3a8206e55
commit
840f236c60
3 changed files with 40 additions and 23 deletions
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug",
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${command:cmake.launchTargetPath}",
|
||||||
|
"args": [],
|
||||||
|
// CHANGE THIS LINE:
|
||||||
|
// Point the working directory to the folder containing the executable
|
||||||
|
"cwd": "${command:cmake.launchTargetDirectory}",
|
||||||
|
"preLaunchTask": "CMake: build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
23
.vscode/tasks.json
vendored
23
.vscode/tasks.json
vendored
|
|
@ -2,16 +2,23 @@
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "CMake: Configure",
|
"label": "CMake: build",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
|
"command": "/usr/bin/cmake",
|
||||||
"problemMatcher": []
|
"args": [
|
||||||
|
"--build",
|
||||||
|
"${workspaceFolder}/build",
|
||||||
|
"--config",
|
||||||
|
"Debug",
|
||||||
|
"--target",
|
||||||
|
"${command:cmake.buildTargetName}"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
},
|
},
|
||||||
{
|
"problemMatcher": "$gcc",
|
||||||
"label": "CMake: Build",
|
"detail": "Builds the target currently selected in the CMake status bar"
|
||||||
"type": "shell",
|
|
||||||
"command": "cmake --build build -- -j",
|
|
||||||
"problemMatcher": []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,12 @@
|
||||||
#include <algorithm>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <expected>
|
#include <expected>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <functional>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
|
||||||
#include <map>
|
|
||||||
#include <mdspan>
|
#include <mdspan>
|
||||||
#include <numeric>
|
|
||||||
#include <print>
|
#include <print>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct Diagram {
|
struct Diagram {
|
||||||
|
|
@ -25,6 +19,7 @@ struct Diagram {
|
||||||
auto grid() { return GridView(data.data(), height, width); }
|
auto grid() { return GridView(data.data(), height, width); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace {
|
||||||
auto printMap(Diagram &diagram) {
|
auto printMap(Diagram &diagram) {
|
||||||
auto grid = diagram.grid();
|
auto grid = diagram.grid();
|
||||||
for (auto row = 0UZ; row != grid.extent(0); row++) {
|
for (auto row = 0UZ; row != grid.extent(0); row++) {
|
||||||
|
|
@ -37,7 +32,6 @@ auto printMap(Diagram &diagram) {
|
||||||
std::println("Width: {}", diagram.width);
|
std::println("Width: {}", diagram.width);
|
||||||
std::println("Height: {}", diagram.height);
|
std::println("Height: {}", diagram.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto parseMap(const std::string &filename) -> std::expected<Diagram, std::string> {
|
auto parseMap(const std::string &filename) -> std::expected<Diagram, std::string> {
|
||||||
std::ifstream inputF{filename};
|
std::ifstream inputF{filename};
|
||||||
|
|
||||||
|
|
@ -143,7 +137,7 @@ auto moveMoveablePaper(Diagram &diagram) -> long {
|
||||||
|
|
||||||
return totalPaperRemoved;
|
return totalPaperRemoved;
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
auto main() -> int {
|
auto main() -> int {
|
||||||
auto testCase = parseMap("test_input");
|
auto testCase = parseMap("test_input");
|
||||||
if (testCase) {
|
if (testCase) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue