Skip to content

Commit

Permalink
Cpp17 support for anyany.hpp (#40)
Browse files Browse the repository at this point in the history
* C++17 support
* Method now is a typename, not a template typename
* .type_descriptor() now is not default(enabled by aa::type_info)
* new macros: anyany_method/anyany_extern_method/anyany_pseudomethod (see anyany/anyany_macro.hpp for syntax and details)
* allow duplicate methods like any_with<A, A, A, B, B, A, A>
* pseudomethods (values in vtable, invoke returns them instead of call)
* reduce header dependency
* separate header
* materialize for references with 'destroy' and 'copy'
* concepts method/regular_method/pseudomethod
* examples are separate cmake project now
  • Loading branch information
kelbon authored May 7, 2023
1 parent cc409e2 commit ad8c1ea
Show file tree
Hide file tree
Showing 38 changed files with 3,648 additions and 2,924 deletions.
5 changes: 3 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BasedOnStyle: Google
ColumnLimit : 110
AllowShortFunctionsOnASingleLine: false
AllowShortLambdasOnASingleLine: Inline
AllowShortLambdasOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
SortIncludes: false
47 changes: 47 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: build_and_test

on: push

jobs:
build:
strategy:
matrix:
os: [ubuntu-22.04]
compiler: [g++-12, clang++-14]
cpp_standard: [17, 20]
build_type: [Debug, Release]
runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install ninja-build lld gcc-12 clang-14
sudo ln -sf /usr/local/bin/ld /usr/bin/lld
- name: Configure CMake
run: |
cmake . -DAA_ENABLE_TESTING=ON \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_COMPILER=${{matrix.compiler}} \
-DCMAKE_CXX_STANDARD=${{matrix.cpp_standard}} \
-B build -G "Ninja"
- name: Build
run:
cmake --build build

- name: Test
run: |
cd build
ctest --output-on-failure -C ${{matrix.build_type}} -V
- name: Run examples
run: |
cd examples
cmake . -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_COMPILER=${{matrix.compiler}} \
-DCMAKE_CXX_STANDARD=${{matrix.cpp_standard}} \
-B build -G "Ninja"
cmake --build build
cd build
ctest --output-on-failure -C ${{matrix.build_type}} -V
33 changes: 0 additions & 33 deletions .github/workflows/clang.yml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/gcc.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build*
/build*
/examples/build
21 changes: 12 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,36 @@ project(anyany LANGUAGES CXX)

option(AA_ENABLE_TESTING "enables testing" OFF)

file(GLOB ${PROJECT_NAME}_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp")
file(GLOB ${PROJECT_NAME}_NOEXPORT_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/noexport/*.hpp")
file(GLOB ${PROJECT_NAME}_EXAMPLES "${CMAKE_CURRENT_SOURCE_DIR}/examples/*")
file(GLOB ${PROJECT_NAME}_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/anyany/*.hpp")
file(GLOB ${PROJECT_NAME}_NOEXPORT_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/anyany/noexport/*.hpp")

### anyanylib ###

add_library(${PROJECT_NAME}lib INTERFACE "${${PROJECT_NAME}_HEADERS}"
"${${PROJECT_NAME}_NOEXPORT_HEADERS}"
"${${PROJECT_NAME}_EXAMPLES}")
add_library(anyanylib INTERFACE "${${PROJECT_NAME}_HEADERS}" "${${PROJECT_NAME}_NOEXPORT_HEADERS}")

target_include_directories(${PROJECT_NAME}lib INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(anyanylib INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")

set_target_properties(${PROJECT_NAME}lib PROPERTIES
CMAKE_CXX_EXTENSIONS OFF
LINKER_LANGUAGE CXX
CMAKE_CXX_STANDARD_REQUIRED ON
CXX_STANDARD 20)
CXX_STANDARD 17)

### visual ###

source_group(Details FILES ${${PROJECT_NAME}_NOEXPORT_HEADERS})
source_group(Include FILES ${${PROJECT_NAME}_HEADERS})
source_group(Examples FILES ${${PROJECT_NAME}_EXAMPLES})

### tests ###

if(AA_ENABLE_TESTING)
include(CTest)
add_subdirectory(tests)
endif()
if(MSVC)
# asks stupid MSVC to work as C++ standard says, asks separatelly MSVC-preprocessor to work as C++ standard says
# additionally asks MSVC to SHOW UP CORRECTLY __cplusplus VERSION OMG
# and of course disables two warnings about "oh, im stupid msvc, support of this attribute in C++17 is an extension..."
# THEN FCN IGNORE IT, IT IS FOR WHAT ATTRIBUTES EXIST
target_compile_options(${PROJECT_NAME}lib INTERFACE "/Zc:__cplusplus" "/Zc:preprocessor" "/permissive-" "/wd5051" "/wd4848")
endif()
Loading

0 comments on commit ad8c1ea

Please sign in to comment.