Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ parsers:

ignore:
- "tests/"
- "examples/"
1 change: 1 addition & 0 deletions .fossa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ vendoredDependencies:
exclude:
- ".git/**"
- "tests/**"
- "examples/**"
- "ci/**"
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- '.github/workflows/build.yml'
- 'include/**'
- 'tests/**'
- 'examples/**'
- 'CMakeLists.txt'
- 'cmake/**'
- 'nix/**'
Expand All @@ -20,6 +21,7 @@ on:
- '.github/workflows/build.yml'
- 'include/**'
- 'tests/**'
- 'examples/**'
- 'CMakeLists.txt'
- 'cmake/**'
- 'nix/**'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ on:
- '.codecov.yml'
workflow_dispatch:

# examples/** not included in coverage paths intentionally, see also .codecov.yml

jobs:
coverage:
runs-on:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'docs/**'
- 'include/**'
- 'tests/**'
- 'examples/**'
- 'CMakeLists.txt'
- 'cmake/**'
- '*.md'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/licence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- '.github/workflows/licence.yml'
- 'include/**'
- 'tests/**'
- 'examples/**'
- 'CMakeLists.txt'
- 'cmake/**'
- '.fossa.yml'
Expand All @@ -19,6 +20,7 @@ on:
- '.github/workflows/licence.yml'
- 'include/**'
- 'tests/**'
- 'examples/**'
- 'CMakeLists.txt'
- 'cmake/**'
- '.fossa.yml'
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ if(TESTS)
add_subdirectory(tests)
endif()

add_subdirectory(examples)

install(FILES README.md LICENSE.md
DESTINATION share/doc/functional)
2 changes: 1 addition & 1 deletion cmake/Coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ setup_target_for_coverage_gcovr(
FORMAT ${CODE_COVERAGE_FORMAT}
EXECUTABLE ${CODE_COVERAGE_TEST}
EXECUTABLE_ARGS ${CODE_COVERAGE_TEST_ARGS}
EXCLUDE "tests"
EXCLUDE "tests" "examples"
DEPENDENCIES all
)

Expand Down
2 changes: 1 addition & 1 deletion docs/choice/and_then.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ A monadic type of the same kind.
## Examples {style: "api"}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-choice-parse", "// example-choice-checks"]
}
4 changes: 2 additions & 2 deletions docs/expected/and_then.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ A monadic type of the same kind.
## Examples {style: "api"}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-error-struct", "// example-expected-and_then-value"],
desc: "The resulting value is `13` because `ex` does not contain an `Error` and therefore `and_then` is called."
}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-error-struct", "// example-expected-and_then-error"],
desc: "The result is an `Error` because `ex` already contained an `Error` and therefore `and_then` is not called."
}
2 changes: 1 addition & 1 deletion docs/expected/discard.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void
## Examples {style: "api"}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-error-struct", "// example-expected-discard"],
desc: "`42` is observed by `inspect` and the value is discarded by `discard` (no warning for discarded result of `inspect`)."
}
4 changes: 2 additions & 2 deletions docs/expected/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ A monadic type of the same kind.
## Examples {style: "api"}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-error-struct", "// example-expected-filter-value"],
desc: "The resulting value is `42` because the filter predicate returns `true` for `42` as it is not less than `42`."
}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-error-struct", "// example-expected-filter-error"],
desc: "The error is set to `Less than 42` because the predicate returns `false` for `12` since it's less than `42`."
}
1 change: 1 addition & 0 deletions docs/lookup-paths
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
../tests/
../examples/
../include/
4 changes: 2 additions & 2 deletions docs/optional/and_then.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ A monadic type of the same kind.
## Examples {style: "api"}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-optional-and_then-value"],
desc: "The resulting value is `13` because `op` is not a `nullopt` and therefore `and_then` is called."
}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-optional-and_then-empty"],
desc: "The result is a `nullopt` because `op` was already a `nullopt` and therefore `and_then` is not called."
}
2 changes: 1 addition & 1 deletion docs/optional/discard.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void
## Examples {style: "api"}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-error-struct", "// example-optional-discard"],
desc: "`42` is observed by `inspect` and the value is discarded by `discard` (no warning for discarded result of `inspect`)."
}
4 changes: 2 additions & 2 deletions docs/optional/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ A monadic type of the same kind.
## Examples {style: "api"}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-optional-filter-value"],
desc: "The resulting value is `42` because the filter predicate returns `true` for `42` as it is not less than `42`."
}

:include-template: templates/snippet.md {
path: "examples/simple.cpp",
path: "simple/main.cpp",
surroundedBy: ["// example-optional-filter-empty"],
desc: "The optional is empty because the predicate returns `false` for `12` since it's less than `42`."
}
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.25)

add_subdirectory(simple)
add_subdirectory(polygon)
24 changes: 24 additions & 0 deletions examples/polygon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.25)
project(examples_polygon)

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Pls keep the filenames sorted
set(TESTS_EXAMPLES_POLYGON_SOURCES
main.cpp
)

# TODO add 20 when we are compatible with C++20
foreach(mode 23)
set(target "examples_polygon_cxx${mode}")

add_executable("${target}" ${TESTS_EXAMPLES_POLYGON_SOURCES})
target_link_libraries("${target}" include_fn)
append_compilation_options("${target}" WARNINGS)
add_dependencies("cxx${mode}" "${target}")
set_property(TARGET "${target}" PROPERTY CXX_STANDARD "${mode}")
target_compile_definitions("${target}" PRIVATE LIBFN_MODE=${mode})

unset(target)
endforeach()
Loading