Skip to content

Commit 35cfaa4

Browse files
committed
🆕 Initial version of C++17 Type.Erasure library
Problem: - There are a lot of Type.Erasure libraries for C++, however all of them require a lot of boilerplate. Solution: - Try to implement a Type.Ereasure library with minimal boilerplate.
0 parents  commit 35cfaa4

20 files changed

+1527
-0
lines changed

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
---

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

.travis.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#
2+
# Copyright (c) 2018 Kris Jusiak (kris at jusiak dot net)
3+
#
4+
# Distributed under the Boost Software License, Version 1.0.
5+
# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
dist: trusty
8+
sudo: required
9+
10+
matrix:
11+
fast_finish: true
12+
include:
13+
14+
- os: linux
15+
env: CXX=clang++-4.0 VARIANT=valgrind
16+
addons: { apt: { packages: ["clang-4.0", "libstdc++-6-dev", "valgrind"], sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-4.0"] } }
17+
18+
- os: linux
19+
env: CXX=clang++-5.0 VARIANT=valgrind
20+
addons: { apt: { packages: ["clang-5.0", "libstdc++-6-dev", "valgrind"], sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-5.0"] } }
21+
22+
- os: linux
23+
env: CXX=clang++-5.0 VARIANT=sanitizers
24+
addons: { apt: { packages: ["clang-5.0", "libstdc++-6-dev"], sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-5.0"] } }
25+
26+
- os: linux
27+
env: CXX=g++-7 VARIANT=valgrind
28+
addons: { apt: { packages: ["g++-7", "libstdc++-7-dev", "valgrind"], sources: ["ubuntu-toolchain-r-test"] } }
29+
30+
- os: linux
31+
env: CXX=g++-7 VARIANT=coverage
32+
addons: { apt: { packages: ["g++-7", "libstdc++-7-dev"], sources: ["ubuntu-toolchain-r-test"] } }
33+
34+
- os: osx
35+
osx_image: xcode9.1
36+
env: CXX=clang++ VARIANT=valgrind
37+
38+
script:
39+
- if [ "${VARIANT}" == "valgrind" ]; then (
40+
cmake -Bbuild/debug -DCMAKE_BUILD_TYPE=Debug -DENABLE_MEMCHECK=ON -H. && cmake --build build/debug &&
41+
cmake -Bbuild/release -DCMAKE_BUILD_TYPE=Release -DENABLE_MEMCHECK=ON -H. && cmake --build build/release
42+
); fi
43+
- if [ "${VARIANT}" == "sanitizers" ]; then (
44+
cmake -Bbuild/debug/sanitizers -DCMAKE_BUILD_TYPE=Debug -DENABLE_SANITIZERS=ON -H. && cmake --build build/debug/sanitizers
45+
); fi
46+
- if [ "${VARIANT}" == "coverage" ]; then (
47+
cmake -Bbuild/debug/coverage -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON -H. && cmake --build build/debug/coverage &&
48+
bash <(curl -s https://codecov.io/bash)
49+
); fi
50+
51+
notifications:
52+
on_success: change
53+
on_failure: always
54+
on_start: false

CMakeLists.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# Copyright (c) 2018 Kris Jusiak (kris at jusiak dot net)
3+
#
4+
# Distributed under the Boost Software License, Version 1.0.
5+
# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
cmake_minimum_required(VERSION 2.8)
8+
project(Type.Erasure CXX)
9+
10+
option(ENABLE_MEMCHECK "Run the unit tests and examples under valgrind if it is found." OFF)
11+
option(ENABLE_COVERAGE "Run coverage." OFF)
12+
option(ENABLE_SANITIZERS "Run static analysis." OFF)
13+
14+
add_custom_target(style)
15+
add_custom_command(TARGET style COMMAND find ${CMAKE_CURRENT_LIST_DIR}/example
16+
${CMAKE_CURRENT_LIST_DIR}/include ${CMAKE_CURRENT_LIST_DIR}/test -iname
17+
"*.hpp" -or -iname "*.cpp" | xargs clang-format -i)
18+
19+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")
20+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
21+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
22+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
23+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
24+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
25+
26+
if (ENABLE_COVERAGE)
27+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
29+
endif()
30+
31+
if (ENABLE_SANITIZERS)
32+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -fno-omit-frame-pointer -fsanitize=address -fsanitize=leak -fsanitize=undefined")
33+
endif()
34+
35+
enable_testing()
36+
37+
include_directories(include)
38+
39+
find_program(MEMORYCHECK_COMMAND valgrind)
40+
if (ENABLE_MEMCHECK AND MEMORYCHECK_COMMAND)
41+
function(test name)
42+
string(REPLACE "/" "_" out ${name})
43+
add_executable(${out} ${CMAKE_CURRENT_LIST_DIR}/${name}.cpp)
44+
add_custom_command(TARGET ${out} COMMAND ${MEMORYCHECK_COMMAND} --leak-check=full --error-exitcode=1 ./${out})
45+
endfunction()
46+
else()
47+
function(test name)
48+
string(REPLACE "/" "_" out ${name})
49+
add_executable(${out} ${CMAKE_CURRENT_LIST_DIR}/${name}.cpp)
50+
add_custom_command(TARGET ${out} COMMAND ./${out})
51+
endfunction()
52+
endif()
53+
54+
add_subdirectory(example)
55+
add_subdirectory(test)

0 commit comments

Comments
 (0)