Skip to content

Commit

Permalink
Updated to require C++17 and use exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdulcet committed Nov 13, 2024
1 parent 370dde9 commit 8fa05e2
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 273 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
$CXX --version
- name: Script
run: |
ARGS=( -std=gnu++14 -Wall -g -Og )
ARGS=( -std=gnu++17 -Wall -g -Og )
if [[ $CXX == clang* ]]; then
ARGS+=( -fsanitize=address,undefined,integer )
else
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ target_sources(tglib_tables PUBLIC

# compile example binaries as executables
if (PROJECT_IS_TOP_LEVEL)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(tglib_graphs_example "${CMAKE_CURRENT_SOURCE_DIR}/graphs.cpp")
target_link_libraries(tglib_graphs_example PRIVATE tglib::graphs)
Expand Down
42 changes: 14 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ For command-line tools using these respective libraries, see the [Tables and Gra

### Usage

Requires support for C++14. See the [tables.hpp](tables.hpp) file for full usage information.
Requires support for C++17. See the [tables.hpp](tables.hpp) file for full usage information.

Complete versions of all of the examples below and more can be found in the [tables.cpp](tables.cpp) file.

Compile with:
* GCC: `g++ -std=c++14 -Wall -g -O3 tables.cpp -o tables`
* Clang: `clang++ -std=c++14 -Wall -g -O3 tables.cpp -o tables`
* GCC: `g++ -std=c++17 -Wall -g -O3 tables.cpp -o tables`
* Clang: `clang++ -std=c++17 -Wall -g -O3 tables.cpp -o tables`

Other compilers should work as well, but are not (yet) tested.

Expand All @@ -68,9 +68,7 @@ int main()

// Allocate and set array

tables::options aoptions;
aoptions.headerrow = true;
aoptions.headercolumn = true;
tables::options aoptions = {.headerrow = true, .headercolumn = true};

tables::array(rows, columns, array, nullptr, nullptr, aoptions);

Expand Down Expand Up @@ -99,9 +97,7 @@ int main()
string *headerrow = nullptr;
string *headercolumn = nullptr;

tables::options aoptions;
aoptions.headerrow = true;
aoptions.headercolumn = true;
tables::options aoptions = {.headerrow = true, .headercolumn = true};

tables::array(array, headerrow, headercolumn, aoptions);

Expand Down Expand Up @@ -134,9 +130,7 @@ int main()

// Allocate and set array

tables::options aoptions;
aoptions.headerrow = true;
aoptions.headercolumn = true;
tables::options aoptions = {.headerrow = true, .headercolumn = true};

tables::array(rows, columns, array, headerrow, headercolumn, aoptions);

Expand Down Expand Up @@ -165,11 +159,7 @@ int main()

// Set array

tables::options aoptions;
aoptions.headerrow = true;
aoptions.headercolumn = true;
// or with C++20:
// tables::options aoptions{.headerrow = true, .headercolumn = true};
tables::options aoptions = {.headerrow = true, .headercolumn = true};

tables::array(array, headerrow, headercolumn, aoptions);

Expand Down Expand Up @@ -337,8 +327,7 @@ int main()
double xmax = 10;
double xstep = 0.5;

tables::options aoptions;
aoptions.headerrow = true;
tables::options aoptions = {.headerrow = true};

tables::function(xmin, xmax, xstep, afunction, aoptions);

Expand All @@ -362,8 +351,7 @@ int main()
function<double(double)> afunction = [](auto x)
{ return x + 1; };
tables::options aoptions;
aoptions.headerrow = true;
tables::options aoptions = {.headerrow = true};
tables::function(xmin, xmax, xstep, afunction, aoptions);
Expand Down Expand Up @@ -404,8 +392,7 @@ int main()
// Function parameter and return value can be any data type, as long as they are the same
function<double(double)> functions[] = {function1, function2};

tables::options aoptions;
aoptions.headerrow = true;
tables::options aoptions = {.headerrow = true};

tables::functions(xmin, xmax, xstep, numfunctions, functions, aoptions);

Expand Down Expand Up @@ -435,8 +422,7 @@ int main()
[](auto x)
{ return pow(x, 2); }};
tables::options aoptions;
aoptions.headerrow = true;
tables::options aoptions = {.headerrow = true};
tables::functions(xmin, xmax, xstep, numfunctions, functions, aoptions);
Expand Down Expand Up @@ -538,13 +524,13 @@ Check that the width of the table is not greater then the width of the terminal.

### Usage

Requires support for C++14. See the [graphs.hpp](graphs.hpp) file for full usage information.
Requires support for C++17. See the [graphs.hpp](graphs.hpp) file for full usage information.

Complete versions of all of the examples below and more can be found in the [graphs.cpp](graphs.cpp) file.

Compile with:
* GCC: `g++ -std=c++14 -Wall -g -O3 graphs.cpp -o graphs`
* Clang: `clang++ -std=c++14 -Wall -g -O3 graphs.cpp -o graphs`
* GCC: `g++ -std=c++17 -Wall -g -O3 graphs.cpp -o graphs`
* Clang: `clang++ -std=c++17 -Wall -g -O3 graphs.cpp -o graphs`

Other compilers should work as well, but are not (yet) tested.

Expand Down
12 changes: 6 additions & 6 deletions graphs.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Teal Dulcet, CS546

// Compile: g++ -std=c++14 -Wall -g -O3 graphs.cpp -o graphs
// Compile: g++ -std=gnu++17 -Wall -g -O3 graphs.cpp -o graphs

// Run: ./graphs

Expand Down Expand Up @@ -242,7 +242,7 @@ int main()
{
aoptions.style = style;

graphs::functions(height, width, xmin, xmax, ymin, ymax, graphs::size(functions), functions, aoptions);
graphs::functions(height, width, xmin, xmax, ymin, ymax, size(functions), functions, aoptions);
}
}
{
Expand All @@ -257,7 +257,7 @@ int main()
{
aoptions.style = style;

graphs::functions(height, width, xmin, xmax, ymin, ymax, graphs::size(functions), functions, aoptions);
graphs::functions(height, width, xmin, xmax, ymin, ymax, size(functions), functions, aoptions);
}
}
{
Expand All @@ -270,13 +270,13 @@ int main()

graphs::options aoptions;
aoptions.axisunitslabel = false;
// graphs::options aoptions{.axisunitslabel = false};
// graphs::options aoptions = {.axisunitslabel = false};

for (const graphs::style_type style : graphs::style_types)
{
aoptions.style = style;

graphs::functions(height, width, xmin, xmax, ymin, ymax, graphs::size(functions), functions, aoptions);
graphs::functions(height, width, xmin, xmax, ymin, ymax, size(functions), functions, aoptions);
}

/* aoptions.style = 2;
Expand All @@ -286,7 +286,7 @@ int main()
cout << "\e[1;1H"
<< "\e[2J";
graphs::functions(k, k, xmin, xmax, ymin, ymax, graphs::size(functions), functions, aoptions);
graphs::functions(k, k, xmin, xmax, ymin, ymax, size(functions), functions, aoptions);
usleep(200000);
} */
Expand Down
Loading

0 comments on commit 8fa05e2

Please sign in to comment.