new ci scripts and presets

This commit is contained in:
BlackMATov
2022-12-29 01:16:54 +07:00
parent ce142df971
commit a21a6bd4ca
59 changed files with 650 additions and 7459 deletions

View File

@@ -1,19 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/coverage"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_COVERAGE=ON)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && lcov -d . -z)
(cd "${BUILD_DIR}" && ctest --verbose)
(cd "${BUILD_DIR}" && lcov -d . -c -o "coverage.info")
(cd "${BUILD_DIR}" && lcov -r "coverage.info" "*/usr/*" "*/untests/*" -o "coverage.info")
(cd "${BUILD_DIR}" && lcov -l "coverage.info")
bash <(curl -s https://codecov.io/bash) -f "${BUILD_DIR}/coverage.info" || echo "Codecov did not collect coverage reports"

View File

@@ -1,11 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/darwin_release"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ctest --verbose)

View File

@@ -1,11 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/linux_release"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ctest --verbose)

View File

@@ -1,19 +0,0 @@
@echo off
set DIR=%~dp0
set ROOT_DIR=%DIR%..\
set BUILD_DIR=%ROOT_DIR%build\windows_release_x64\
if not exist %BUILD_DIR% mkdir %BUILD_DIR% || goto :error
pushd %BUILD_DIR% || goto :error
cmake %ROOT_DIR% -A x64 || goto :error
cmake --build . --config Release || goto :error
ctest --verbose || goto :error
popd || goto :error
goto :EOF
:error
echo Failed with error #%errorlevel%.
exit /b %errorlevel%

View File

@@ -1,19 +0,0 @@
@echo off
set DIR=%~dp0
set ROOT_DIR=%DIR%..\
set BUILD_DIR=%ROOT_DIR%build\windows_release_x86\
if not exist %BUILD_DIR% mkdir %BUILD_DIR% || goto :error
pushd %BUILD_DIR% || goto :error
cmake %ROOT_DIR% -A Win32 || goto :error
cmake --build . --config Release || goto :error
ctest --verbose || goto :error
popd || goto :error
goto :EOF
:error
echo Failed with error #%errorlevel%.
exit /b %errorlevel%

27
.clang-tidy Normal file
View File

@@ -0,0 +1,27 @@
---
Checks: '-*,
bugprone-*,
clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-bounds-constant-array-index,
modernize-*,
-modernize-use-auto,
-modernize-use-trailing-return-type,
performance-*,
portability-*,
readability-*,
-readability-identifier-length,
-readability-named-parameter,
-readability-redundant-access-specifiers,
'
...

View File

@@ -1,16 +0,0 @@
name: coverage
on: [push, pull_request]
jobs:
build:
runs-on: macos-10.15
name: "coverage"
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install lcov by Homebrew
run: brew install lcov
- name: Build && Test && Upload
run: .ci/build_coverage.sh

View File

@@ -10,15 +10,22 @@ jobs:
matrix:
config:
# https://github.com/actions/virtual-environments/tree/main/images/macos
- { os: "macos-10.15", xcode: "10.3" }
- { os: "macos-10.15", xcode: "11.7" }
- { os: "macos-10.15", xcode: "12.4" }
- { os: "macos-10.15", xcode: "10.3", arch: "x64" }
- { os: "macos-12", xcode: "14.2", arch: "x64" }
name: "xcode-${{matrix.config.xcode}}"
steps:
- uses: actions/checkout@v2
- name: Setup
run: brew install cmake ninja
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
submodules: true
- name: Select Xcode
run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app"
- name: Build && Test
run: .ci/build_darwin.sh
- name: Build
run: |
cmake --preset macos-${{matrix.config.arch}}
cmake --build --preset macos-${{matrix.config.arch}}-release
- name: Test
run: |
ctest --preset macos-${{matrix.config.arch}}-release

View File

@@ -11,21 +11,21 @@ jobs:
config:
# https://github.com/actions/virtual-environments/tree/main/images/linux
- { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" }
- { os: "ubuntu-20.04", cc: "gcc-8", cxx: "g++-8" }
- { os: "ubuntu-20.04", cc: "gcc-9", cxx: "g++-9" }
- { os: "ubuntu-20.04", cc: "gcc-10", cxx: "g++-10" }
- { os: "ubuntu-20.04", cc: "clang-7", cxx: "clang++-7" }
- { os: "ubuntu-20.04", cc: "clang-8", cxx: "clang++-8" }
- { os: "ubuntu-20.04", cc: "clang-9", cxx: "clang++-9" }
- { os: "ubuntu-20.04", cc: "clang-10", cxx: "clang++-10" }
- { os: "ubuntu-22.04", cc: "gcc-12", cxx: "g++-12" }
- { os: "ubuntu-22.04", cc: "clang-14", cxx: "clang++-14" }
name: "${{matrix.config.cxx}}"
steps:
- name: Setup
run: sudo apt-get -y install "${{matrix.config.cc}}" "${{matrix.config.cxx}}"
run: sudo apt-get -y install cmake ninja-build ${{matrix.config.cc}} ${{matrix.config.cxx}}
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build && Test
run: .ci/build_linux.sh
env: { CC: "${{matrix.config.cc}}", CXX: "${{matrix.config.cxx}}" }
submodules: true
- name: Build
run: |
cmake --preset linux-${{matrix.config.cc}}
cmake --build --preset linux-${{matrix.config.cc}}-release
- name: Test
run: |
ctest --preset linux-${{matrix.config.cc}}-release

View File

@@ -10,14 +10,24 @@ jobs:
matrix:
config:
# https://github.com/actions/virtual-environments/tree/main/images/win
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x86" }
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x64" }
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x86" }
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x64" }
name: "${{matrix.config.vs}} ${{matrix.config.arch}}"
- { os: "windows-2019", vc: "msvc2019", arch: "x86" }
- { os: "windows-2019", vc: "msvc2019", arch: "x64" }
- { os: "windows-2022", vc: "msvc2022", arch: "x86" }
- { os: "windows-2022", vc: "msvc2022", arch: "x64" }
name: "${{matrix.config.vc}} ${{matrix.config.arch}}"
steps:
- uses: actions/checkout@v2
- name: Setup
run: choco install cmake ninja
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build && Test
run: .ci\build_windows_${{matrix.config.arch}}.bat
submodules: true
- name: Select MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Build
run: |
cmake --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}
cmake --build --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
- name: Test
run: |
ctest --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
build/*
.clangd/*
.vscode/*
CMakeLists.txt.user

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "vendors/doctest"]
path = vendors/doctest
url = https://github.com/doctest/doctest/

View File

@@ -1,5 +1,4 @@
# 3.8 version is required for `cxx_std_17`
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
if(NOT DEFINED PROJECT_NAME)
set(BUILD_AS_STANDALONE ON)
@@ -10,27 +9,28 @@ endif()
project(flat.hpp)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE headers)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
target_include_directories(${PROJECT_NAME} INTERFACE headers)
target_compile_options(${PROJECT_NAME}
INTERFACE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-Wno-c++98-compat-pedantic
-Wno-padded
-Wno-shadow
-Wno-unknown-warning-option>)
#
# BUILD_AS_STANDALONE
#
if(BUILD_AS_STANDALONE)
option(BUILD_WITH_UNBENCH "Build with benchmarks" OFF)
if(BUILD_WITH_UNBENCH)
enable_testing()
add_subdirectory(unbench)
endif()
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
if(BUILD_WITH_UNTESTS)
enable_testing()
add_subdirectory(untests)
endif()
if(NOT ${BUILD_AS_STANDALONE})
return()
endif()
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
enable_testing()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(EnableASan)
include(EnableGCov)
include(EnableUBSan)
add_subdirectory(vendors)
add_subdirectory(untests)

342
CMakePresets.json Normal file
View File

@@ -0,0 +1,342 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "ninja-base",
"hidden": true,
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/install/${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": true
}
},
{
"name": "linux-base",
"hidden": true,
"inherits": "ninja-base",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "linux-clang-7",
"inherits": "linux-base",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-7",
"CMAKE_CXX_COMPILER": "clang++-7"
}
},
{
"name": "linux-clang-14",
"inherits": "linux-base",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-14",
"CMAKE_CXX_COMPILER": "clang++-14"
}
},
{
"name": "linux-gcc-7",
"inherits": "linux-base",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc-7",
"CMAKE_CXX_COMPILER": "g++-7"
}
},
{
"name": "linux-gcc-12",
"inherits": "linux-base",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc-12",
"CMAKE_CXX_COMPILER": "g++-12"
}
},
{
"name": "macos-base",
"hidden": true,
"inherits": "ninja-base",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "macos-arm64",
"inherits": "macos-base",
"architecture": {
"value": "arm64",
"strategy": "external"
}
},
{
"name": "macos-arm64-san",
"inherits": "macos-arm64",
"cacheVariables": {
"BUILD_WITH_SANITIZERS": true
}
},
{
"name": "macos-x64",
"inherits": "macos-base",
"architecture": {
"value": "x64",
"strategy": "external"
}
},
{
"name": "macos-x64-san",
"inherits": "macos-x64",
"cacheVariables": {
"BUILD_WITH_SANITIZERS": true
}
},
{
"name": "windows-base",
"hidden": true,
"inherits": "ninja-base",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "windows-x86-msvc2019",
"inherits": "windows-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"toolset": {
"value": "v142,host=x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
}
},
{
"name": "windows-x64-msvc2019",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "v142,host=x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
}
},
{
"name": "windows-x86-msvc2022",
"inherits": "windows-base",
"architecture": {
"value": "x86",
"strategy": "external"
},
"toolset": {
"value": "v143,host=x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
}
},
{
"name": "windows-x64-msvc2022",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "v143,host=x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
}
}
],
"buildPresets": [
{
"name": "linux-clang-7-debug",
"configuration": "Debug",
"configurePreset": "linux-clang-7"
},
{
"name": "linux-clang-7-release",
"configuration": "Release",
"configurePreset": "linux-clang-7"
},
{
"name": "linux-clang-14-debug",
"configuration": "Debug",
"configurePreset": "linux-clang-14"
},
{
"name": "linux-clang-14-release",
"configuration": "Release",
"configurePreset": "linux-clang-14"
},
{
"name": "linux-gcc-7-debug",
"configuration": "Debug",
"configurePreset": "linux-gcc-7"
},
{
"name": "linux-gcc-7-release",
"configuration": "Release",
"configurePreset": "linux-gcc-7"
},
{
"name": "linux-gcc-12-debug",
"configuration": "Debug",
"configurePreset": "linux-gcc-12"
},
{
"name": "linux-gcc-12-release",
"configuration": "Release",
"configurePreset": "linux-gcc-12"
},
{
"name": "macos-arm64-debug",
"configuration": "Debug",
"configurePreset": "macos-arm64-san"
},
{
"name": "macos-arm64-release",
"configuration": "Release",
"configurePreset": "macos-arm64"
},
{
"name": "macos-x64-debug",
"configuration": "Debug",
"configurePreset": "macos-x64-san"
},
{
"name": "macos-x64-release",
"configuration": "Release",
"configurePreset": "macos-x64"
},
{
"name": "windows-x86-msvc2019-debug",
"configuration": "Debug",
"configurePreset": "windows-x86-msvc2019"
},
{
"name": "windows-x86-msvc2019-release",
"configuration": "Release",
"configurePreset": "windows-x86-msvc2019"
},
{
"name": "windows-x64-msvc2019-debug",
"configuration": "Debug",
"configurePreset": "windows-x64-msvc2019"
},
{
"name": "windows-x64-msvc2019-release",
"configuration": "Release",
"configurePreset": "windows-x64-msvc2019"
},
{
"name": "windows-x86-msvc2022-debug",
"configuration": "Debug",
"configurePreset": "windows-x86-msvc2022"
},
{
"name": "windows-x86-msvc2022-release",
"configuration": "Release",
"configurePreset": "windows-x86-msvc2022"
},
{
"name": "windows-x64-msvc2022-debug",
"configuration": "Debug",
"configurePreset": "windows-x64-msvc2022"
},
{
"name": "windows-x64-msvc2022-release",
"configuration": "Release",
"configurePreset": "windows-x64-msvc2022"
}
],
"testPresets": [
{
"name": "test-base",
"hidden": true,
"output": {
"verbosity": "verbose"
},
"configuration": "Release"
},
{
"name": "linux-clang-7-release",
"inherits": "test-base",
"configurePreset": "linux-clang-7"
},
{
"name": "linux-clang-14-release",
"inherits": "test-base",
"configurePreset": "linux-clang-14"
},
{
"name": "linux-gcc-7-release",
"inherits": "test-base",
"configurePreset": "linux-gcc-7"
},
{
"name": "linux-gcc-12-release",
"inherits": "test-base",
"configurePreset": "linux-gcc-12"
},
{
"name": "macos-arm64-release",
"inherits": "test-base",
"configurePreset": "macos-arm64"
},
{
"name": "macos-x64-release",
"inherits": "test-base",
"configurePreset": "macos-x64"
},
{
"name": "windows-x86-msvc2019-release",
"inherits": "test-base",
"configurePreset": "windows-x86-msvc2019"
},
{
"name": "windows-x64-msvc2019-release",
"inherits": "test-base",
"configurePreset": "windows-x64-msvc2019"
},
{
"name": "windows-x86-msvc2022-release",
"inherits": "test-base",
"configurePreset": "windows-x86-msvc2022"
},
{
"name": "windows-x64-msvc2022-release",
"inherits": "test-base",
"configurePreset": "windows-x64-msvc2022"
}
]
}

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -5,21 +5,18 @@
[![linux][badge.linux]][linux]
[![darwin][badge.darwin]][darwin]
[![windows][badge.windows]][windows]
[![codecov][badge.codecov]][codecov]
[![language][badge.language]][language]
[![license][badge.license]][license]
[badge.darwin]: https://img.shields.io/github/workflow/status/BlackMATov/flat.hpp/darwin/main?label=Xcode&logo=xcode
[badge.linux]: https://img.shields.io/github/workflow/status/BlackMATov/flat.hpp/linux/main?label=GCC%2FClang&logo=linux
[badge.windows]: https://img.shields.io/github/workflow/status/BlackMATov/flat.hpp/windows/main?label=Visual%20Studio&logo=visual-studio
[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/flat.hpp/main?logo=codecov
[badge.darwin]: https://img.shields.io/github/actions/workflow/status/BlackMATov/flat.hpp/.github/workflows/darwin.yml?label=Xcode&logo=xcode
[badge.linux]: https://img.shields.io/github/actions/workflow/status/BlackMATov/flat.hpp/.github/workflows/linux.yml?label=GCC%2FClang&logo=linux
[badge.windows]: https://img.shields.io/github/actions/workflow/status/BlackMATov/flat.hpp/.github/workflows/windows.yml?label=Visual%20Studio&logo=visual-studio
[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow
[badge.license]: https://img.shields.io/badge/license-MIT-blue
[darwin]: https://github.com/BlackMATov/flat.hpp/actions?query=workflow%3Adarwin
[linux]: https://github.com/BlackMATov/flat.hpp/actions?query=workflow%3Alinux
[windows]: https://github.com/BlackMATov/flat.hpp/actions?query=workflow%3Awindows
[codecov]: https://codecov.io/gh/BlackMATov/flat.hpp
[language]: https://en.wikipedia.org/wiki/C%2B%2B17
[license]: https://en.wikipedia.org/wiki/MIT_License
@@ -27,9 +24,10 @@
## Requirements
- [clang](https://clang.llvm.org/) **>= 7**
- [gcc](https://www.gnu.org/software/gcc/) **>= 7**
- [clang](https://clang.llvm.org/) **>= 5.0**
- [msvc](https://visualstudio.microsoft.com/) **>= 2017**
- [msvc](https://visualstudio.microsoft.com/) **>= 2019**
- [xcode](https://developer.apple.com/xcode/) **>= 10.3**
## Installation
@@ -37,20 +35,13 @@
```cpp
#include "flat.hpp/flat_set.hpp"
using namespace flat_hpp;
int main() {
flat_set<int> s;
s.insert(42);
return 0;
}
```
Also, you can add the root repository directory to your [cmake](https://cmake.org) project:
```cmake
add_subdirectory(external/flat.hpp)
target_link_libraries(your_project_target flat.hpp)
target_link_libraries(your_project_target PUBLIC flat.hpp)
```
## API

15
cmake/EnableASan.cmake Normal file
View File

@@ -0,0 +1,15 @@
# https://clang.llvm.org/docs/AddressSanitizer.html
add_library(enable_asan INTERFACE)
target_compile_options(enable_asan INTERFACE
-fsanitize=address
-fno-omit-frame-pointer
-fsanitize-address-use-after-scope
-fsanitize-address-use-after-return=always)
target_link_options(enable_asan INTERFACE
-fsanitize=address
-fno-omit-frame-pointer
-fsanitize-address-use-after-scope
-fsanitize-address-use-after-return=always)

9
cmake/EnableGCov.cmake Normal file
View File

@@ -0,0 +1,9 @@
# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
add_library(enable_gcov INTERFACE)
target_compile_options(enable_gcov INTERFACE
--coverage)
target_link_options(enable_gcov INTERFACE
--coverage)

11
cmake/EnableUBSan.cmake Normal file
View File

@@ -0,0 +1,11 @@
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
add_library(enable_ubsan INTERFACE)
target_compile_options(enable_ubsan INTERFACE
-fsanitize=undefined
-fno-omit-frame-pointer)
target_link_options(enable_ubsan INTERFACE
-fsanitize=undefined
-fno-omit-frame-pointer)

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "flat_map.hpp"

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
@@ -54,9 +54,8 @@ namespace flat_hpp
: key_compare(std::move(compare)) {}
};
public:
flat_map()
noexcept(std::is_nothrow_default_constructible_v<base_type>
&& std::is_nothrow_default_constructible_v<container_type>) {}
flat_map() = default;
~flat_map() = default;
explicit flat_map(const Compare& c)
: base_type(c) {}
@@ -218,9 +217,11 @@ namespace flat_hpp
: base_type(static_cast<const base_type&>(other))
, data_(other.data_, a) {}
// NOLINTNEXTLINE(*-noexcept-move-constructor)
flat_map(flat_map&& other) = default;
flat_map(const flat_map& other) = default;
// NOLINTNEXTLINE(*-noexcept-move-constructor)
flat_map& operator=(flat_map&& other) = default;
flat_map& operator=(const flat_map& other) = default;

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
@@ -54,9 +54,8 @@ namespace flat_hpp
: key_compare(std::move(compare)) {}
};
public:
flat_multimap()
noexcept(std::is_nothrow_default_constructible_v<base_type>
&& std::is_nothrow_default_constructible_v<container_type>) {}
flat_multimap() = default;
~flat_multimap() = default;
explicit flat_multimap(const Compare& c)
: base_type(c) {}
@@ -172,9 +171,11 @@ namespace flat_hpp
: base_type(static_cast<const base_type&>(other))
, data_(other.data_, a) {}
// NOLINTNEXTLINE(*-noexcept-move-constructor)
flat_multimap(flat_multimap&& other) = default;
flat_multimap(const flat_multimap& other) = default;
// NOLINTNEXTLINE(*-noexcept-move-constructor)
flat_multimap& operator=(flat_multimap&& other) = default;
flat_multimap& operator=(const flat_multimap& other) = default;

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
@@ -36,9 +36,8 @@ namespace flat_hpp
using reverse_iterator = typename Container::const_reverse_iterator;
using const_reverse_iterator = typename Container::const_reverse_iterator;
public:
flat_multiset()
noexcept(std::is_nothrow_default_constructible_v<base_type>
&& std::is_nothrow_default_constructible_v<container_type>) {}
flat_multiset() = default;
~flat_multiset() = default;
explicit flat_multiset(const Compare& c)
: base_type(c) {}
@@ -154,9 +153,11 @@ namespace flat_hpp
: base_type(static_cast<const base_type&>(other))
, data_(other.data_, a) {}
// NOLINTNEXTLINE(*-noexcept-move-constructor)
flat_multiset(flat_multiset&& other) = default;
flat_multiset(const flat_multiset& other) = default;
// NOLINTNEXTLINE(*-noexcept-move-constructor)
flat_multiset& operator=(flat_multiset&& other) = default;
flat_multiset& operator=(const flat_multiset& other) = default;

View File

@@ -1,7 +1,7 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
@@ -36,9 +36,8 @@ namespace flat_hpp
using reverse_iterator = typename Container::const_reverse_iterator;
using const_reverse_iterator = typename Container::const_reverse_iterator;
public:
flat_set()
noexcept(std::is_nothrow_default_constructible_v<base_type>
&& std::is_nothrow_default_constructible_v<container_type>) {}
flat_set() = default;
~flat_set() = default;
explicit flat_set(const Compare& c)
: base_type(c) {}
@@ -200,9 +199,11 @@ namespace flat_hpp
: base_type(static_cast<const base_type&>(other))
, data_(other.data_, a) {}
// NOLINTNEXTLINE(*-noexcept-move-constructor)
flat_set(flat_set&& other) = default;
flat_set(const flat_set& other) = default;
// NOLINTNEXTLINE(*-noexcept-move-constructor)
flat_set& operator=(flat_set&& other) = default;
flat_set& operator=(const flat_set& other) = default;

View File

@@ -1,123 +0,0 @@
#!/usr/bin/env python3
"""Script to visualize google-benchmark output"""
from __future__ import print_function
import argparse
import sys
import logging
import pandas as pd
import matplotlib.pyplot as plt
logging.basicConfig(format='[%(levelname)s] %(message)s')
METRICS = ['real_time', 'cpu_time', 'bytes_per_second', 'items_per_second']
TRANSFORMS = {
'': lambda x: x,
'inverse': lambda x: 1.0 / x
}
def get_default_ylabel(args):
"""Compute default ylabel for commandline args"""
label = ''
if args.transform == '':
label = args.metric
else:
label = args.transform + '(' + args.metric + ')'
if args.relative_to is not None:
label += ' relative to %s' % args.relative_to
return label
def parse_args():
"""Parse commandline arguments"""
parser = argparse.ArgumentParser(
description='Visualize google-benchmark output')
parser.add_argument(
'-f', metavar='FILE', type=argparse.FileType('r'), default=sys.stdin,
dest='file', help='path to file containing the csv benchmark data')
parser.add_argument(
'-m', metavar='METRIC', choices=METRICS, default=METRICS[0], dest='metric',
help='metric to plot on the y-axis, valid choices are: %s' % ', '.join(METRICS))
parser.add_argument(
'-t', metavar='TRANSFORM', choices=TRANSFORMS.keys(), default='',
help='transform to apply to the chosen metric, valid choices are: %s'
% ', '.join(list(TRANSFORMS)), dest='transform')
parser.add_argument(
'-r', metavar='RELATIVE_TO', type=str, default=None,
dest='relative_to', help='plot metrics relative to this label')
parser.add_argument(
'--xlabel', type=str, default='input size', help='label of the x-axis')
parser.add_argument(
'--ylabel', type=str, help='label of the y-axis')
parser.add_argument(
'--title', type=str, default='', help='title of the plot')
parser.add_argument(
'--logx', action='store_true', help='plot x-axis on a logarithmic scale')
parser.add_argument(
'--logy', action='store_true', help='plot y-axis on a logarithmic scale')
args = parser.parse_args()
if args.ylabel is None:
args.ylabel = get_default_ylabel(args)
return args
def parse_input_size(name):
splits = name.split('/')
if len(splits) == 1:
return 1
return int(splits[1])
def read_data(args):
"""Read and process dataframe using commandline args"""
try:
data = pd.read_csv(args.file, usecols=['name', args.metric])
except ValueError:
msg = 'Could not parse the benchmark data. Did you forget "--benchmark_format=csv"?'
logging.error(msg)
exit(1)
data['label'] = data['name'].apply(lambda x: x.split('/')[0])
data['input'] = data['name'].apply(parse_input_size)
data[args.metric] = data[args.metric].apply(TRANSFORMS[args.transform])
return data
def plot_groups(label_groups, args):
"""Display the processed data"""
for label, group in label_groups.items():
plt.plot(group['input'], group[args.metric], label=label, marker='.')
if args.logx:
plt.xscale('log')
if args.logy:
plt.yscale('log')
plt.xlabel(args.xlabel)
plt.ylabel(args.ylabel)
plt.title(args.title)
plt.legend()
plt.show()
def main():
"""Entry point of the program"""
args = parse_args()
data = read_data(args)
label_groups = {}
for label, group in data.groupby('label'):
label_groups[label] = group.set_index('input', drop=False)
if args.relative_to is not None:
try:
baseline = label_groups[args.relative_to][args.metric].copy()
except KeyError as key:
msg = 'Key %s is not present in the benchmark output'
logging.error(msg, str(key))
exit(1)
if args.relative_to is not None:
for label in label_groups:
label_groups[label][args.metric] /= baseline
plot_groups(label_groups, args)
if __name__ == '__main__':
main()

View File

@@ -1,18 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/unbench"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release\
-DBUILD_WITH_UNBENCH=ON\
-DBUILD_WITH_UNTESTS=OFF)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ./unbench/flat.hpp.unbench\
--benchmark_filter=_map_foreach\
--benchmark_format=csv > benchmark_map_foreach.csv)
(cd "${BUILD_DIR}" && "${ROOT_DIR}/scripts/bench_drawer.py" -f benchmark_map_foreach.csv)

View File

@@ -1,18 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/unbench"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release\
-DBUILD_WITH_UNBENCH=ON\
-DBUILD_WITH_UNTESTS=OFF)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ./unbench/flat.hpp.unbench\
--benchmark_filter=_map_insert\
--benchmark_format=csv > benchmark_map_insert.csv)
(cd "${BUILD_DIR}" && "${ROOT_DIR}/scripts/bench_drawer.py" -f benchmark_map_insert.csv)

View File

@@ -1,18 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/unbench"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release\
-DBUILD_WITH_UNBENCH=ON\
-DBUILD_WITH_UNTESTS=OFF)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ./unbench/flat.hpp.unbench\
--benchmark_filter=_map_lookup\
--benchmark_format=csv > benchmark_map_lookup.csv)
(cd "${BUILD_DIR}" && "${ROOT_DIR}/scripts/bench_drawer.py" -f benchmark_map_lookup.csv)

View File

@@ -1,18 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/unbench"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release\
-DBUILD_WITH_UNBENCH=ON\
-DBUILD_WITH_UNTESTS=OFF)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ./unbench/flat.hpp.unbench\
--benchmark_filter=_set_foreach\
--benchmark_format=csv > benchmark_set_foreach.csv)
(cd "${BUILD_DIR}" && "${ROOT_DIR}/scripts/bench_drawer.py" -f benchmark_set_foreach.csv)

View File

@@ -1,18 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/unbench"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release\
-DBUILD_WITH_UNBENCH=ON\
-DBUILD_WITH_UNTESTS=OFF)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ./unbench/flat.hpp.unbench\
--benchmark_filter=_set_insert\
--benchmark_format=csv > benchmark_set_insert.csv)
(cd "${BUILD_DIR}" && "${ROOT_DIR}/scripts/bench_drawer.py" -f benchmark_set_insert.csv)

View File

@@ -1,18 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/unbench"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release\
-DBUILD_WITH_UNBENCH=ON\
-DBUILD_WITH_UNTESTS=OFF)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ./unbench/flat.hpp.unbench\
--benchmark_filter=_set_lookup\
--benchmark_format=csv > benchmark_set_lookup.csv)
(cd "${BUILD_DIR}" && "${ROOT_DIR}/scripts/bench_drawer.py" -f benchmark_set_lookup.csv)

View File

@@ -1,46 +0,0 @@
# 3.11 version is required for `FetchContent`
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project(flat.hpp.unbench)
#
# boost
#
find_package(Boost
OPTIONAL_COMPONENTS container)
#
# google benchmark
#
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
include(FetchContent)
FetchContent_Declare(
gbench
GIT_REPOSITORY https://github.com/google/benchmark)
FetchContent_GetProperties(gbench)
if(NOT gbench_POPULATED)
FetchContent_Populate(gbench)
add_subdirectory(${gbench_SOURCE_DIR} ${gbench_BINARY_DIR})
endif()
#
# benchmark executable
#
file(GLOB UNBENCH_SOURCES "*.cpp" "*.hpp")
add_executable(${PROJECT_NAME} ${UNBENCH_SOURCES})
target_link_libraries(${PROJECT_NAME}
benchmark_main
flat.hpp)
if(Boost_CONTAINER_FOUND)
target_link_libraries(${PROJECT_NAME}
Boost::container)
target_compile_definitions(${PROJECT_NAME}
PRIVATE BOOST_CONTAINER_FOUND)
endif()

View File

@@ -1,131 +0,0 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#pragma once
#include <set>
#include <map>
#include <deque>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <algorithm>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <benchmark/benchmark.h>
namespace flat_hpp_unbench
{
struct vec2 {
int x = 0;
int y = 0;
vec2(int v) noexcept
: x(v), y(v) {}
bool operator<(const vec2& o) const noexcept {
return
(x < o.x) ||
(x == o.x && y < o.y);
}
bool operator==(const vec2& o) const noexcept {
return x == o.x
&& y == o.y;
}
std::size_t hash() const noexcept {
std::hash<int> hasher;
std::size_t seed = hasher(x);
seed ^= hasher(y) + 0x9e3779b9 + (seed<<6) + (seed>>2);
return seed;
}
};
struct vec4 {
int x = 0;
int y = 0;
int z = 0;
int w = 0;
vec4(int v) noexcept
: x(v), y(v), z(v), w(v) {}
bool operator<(const vec4& o) const noexcept {
return
(x < o.x) ||
(x == o.x && y < o.y) ||
(x == o.x && y == o.y && z < o.z) ||
(x == o.x && y == o.y && z == o.z && w < o.w);
}
bool operator==(const vec4& o) const noexcept {
return x == o.x
&& y == o.y
&& z == o.z
&& w == o.w;
}
std::size_t hash() const noexcept {
std::hash<int> hasher;
std::size_t seed = hasher(x);
seed ^= hasher(y) + 0x9e3779b9 + (seed<<6) + (seed>>2);
seed ^= hasher(z) + 0x9e3779b9 + (seed<<6) + (seed>>2);
seed ^= hasher(w) + 0x9e3779b9 + (seed<<6) + (seed>>2);
return seed;
}
};
inline void generate_random_vector(std::size_t n, std::vector<int>& v) {
std::mt19937 engine(n);
std::uniform_int_distribution<int> dist;
std::vector<int> nv(n);
for ( std::size_t i = 0; i < n; ++i ) {
nv[i] = dist(engine);
}
v = std::move(nv);
}
inline void generate_random_vector(std::size_t n, std::vector<std::pair<int,int>>& v) {
std::mt19937 engine(n);
std::uniform_int_distribution<int> dist;
std::vector<std::pair<int,int>> nv(n);
for ( std::size_t i = 0; i < n; ++i ) {
nv[i] = std::make_pair(dist(engine), dist(engine));
}
v = std::move(nv);
}
inline double min_bench_statistics(const std::vector<double>& v) {
return v.empty()
? 0.0
: *(std::min_element(v.begin(), v.end()));
};
}
namespace std
{
template <>
struct hash<flat_hpp_unbench::vec2> {
size_t operator()(const flat_hpp_unbench::vec2& v) const {
return v.hash();
}
};
template <>
struct hash<flat_hpp_unbench::vec4> {
size_t operator()(const flat_hpp_unbench::vec4& v) const {
return v.hash();
}
};
}

View File

@@ -1,94 +0,0 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "bench_base.hpp"
using namespace flat_hpp_unbench;
#include <flat.hpp/flat_map.hpp>
using namespace flat_hpp;
#ifdef BOOST_CONTAINER_FOUND
# include <boost/container/flat_map.hpp>
#endif
namespace
{
template < typename Value >
void flat_map_foreach(benchmark::State& state) {
std::vector<std::pair<int,int>> v;
generate_random_vector(state.range(), v);
flat_map<int, Value> s(v.begin(), v.end());
for ( auto _ : state ) {
int acc = 0;
for ( const auto& e : s ) {
acc += e.second.x;
}
benchmark::DoNotOptimize(acc);
}
}
#ifdef BOOST_CONTAINER_FOUND
template < typename Value >
void boost_flat_map_foreach(benchmark::State& state) {
std::vector<std::pair<int,int>> v;
generate_random_vector(state.range(), v);
boost::container::flat_map<int, Value> s(v.begin(), v.end());
for ( auto _ : state ) {
int acc = 0;
for ( const auto& e : s ) {
acc += e.second.x;
}
benchmark::DoNotOptimize(acc);
}
}
#endif
template < typename Value >
void std_map_foreach(benchmark::State& state) {
std::vector<std::pair<int,int>> v;
generate_random_vector(state.range(), v);
std::map<int, Value> s(v.begin(), v.end());
for ( auto _ : state ) {
int acc = 0;
for ( const auto& e : s ) {
acc += e.second.x;
}
benchmark::DoNotOptimize(acc);
}
}
template < typename Value >
void std_unordered_map_foreach(benchmark::State& state) {
std::vector<std::pair<int,int>> v;
generate_random_vector(state.range(), v);
std::unordered_map<int, Value> s(v.begin(), v.end());
for ( auto _ : state ) {
int acc = 0;
for ( const auto& e : s ) {
acc += e.second.x;
}
benchmark::DoNotOptimize(acc);
}
}
}
BENCHMARK_TEMPLATE(flat_map_foreach, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#ifdef BOOST_CONTAINER_FOUND
BENCHMARK_TEMPLATE(boost_flat_map_foreach, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#endif
BENCHMARK_TEMPLATE(std_map_foreach, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
BENCHMARK_TEMPLATE(std_unordered_map_foreach, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);

View File

@@ -1,86 +0,0 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "bench_base.hpp"
using namespace flat_hpp_unbench;
#include <flat.hpp/flat_map.hpp>
using namespace flat_hpp;
#ifdef BOOST_CONTAINER_FOUND
# include <boost/container/flat_map.hpp>
#endif
namespace
{
template < typename Value >
void flat_map_insert(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
for ( auto _ : state ) {
flat_map<int, Value> s;
for ( auto e : v ) {
s.emplace(e, e);
}
}
}
#ifdef BOOST_CONTAINER_FOUND
template < typename Value >
void boost_flat_map_insert(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
for ( auto _ : state ) {
boost::container::flat_map<int, Value> s;
for ( auto e : v ) {
s.emplace(e, e);
}
}
}
#endif
template < typename Value >
void std_map_insert(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
for ( auto _ : state ) {
std::map<int, Value> s;
for ( auto e : v ) {
s.emplace(e, e);
}
}
}
template < typename Value >
void std_unordered_map_insert(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
for ( auto _ : state ) {
std::unordered_map<int, Value> s;
for ( auto e : v ) {
s.emplace(e, e);
}
}
}
}
BENCHMARK_TEMPLATE(flat_map_insert, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#ifdef BOOST_CONTAINER_FOUND
BENCHMARK_TEMPLATE(boost_flat_map_insert, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#endif
BENCHMARK_TEMPLATE(std_map_insert, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
BENCHMARK_TEMPLATE(std_unordered_map_insert, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);

View File

@@ -1,90 +0,0 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "bench_base.hpp"
using namespace flat_hpp_unbench;
#include <flat.hpp/flat_map.hpp>
using namespace flat_hpp;
#ifdef BOOST_CONTAINER_FOUND
# include <boost/container/flat_map.hpp>
#endif
namespace
{
template < typename Value >
void flat_map_lookup(benchmark::State& state) {
std::vector<std::pair<int,int>> v;
generate_random_vector(state.range(), v);
flat_map<int, Value> s(v.begin(), v.end());
for ( auto _ : state ) {
for ( auto e : v ) {
benchmark::DoNotOptimize(s.find(e.first));
benchmark::DoNotOptimize(s.find(e.second));
}
}
}
#ifdef BOOST_CONTAINER_FOUND
template < typename Value >
void boost_flat_map_lookup(benchmark::State& state) {
std::vector<std::pair<int,int>> v;
generate_random_vector(state.range(), v);
boost::container::flat_map<int, Value> s(v.begin(), v.end());
for ( auto _ : state ) {
for ( auto e : v ) {
benchmark::DoNotOptimize(s.find(e.first));
benchmark::DoNotOptimize(s.find(e.second));
}
}
}
#endif
template < typename Value >
void std_map_lookup(benchmark::State& state) {
std::vector<std::pair<int,int>> v;
generate_random_vector(state.range(), v);
std::map<int, Value> s(v.begin(), v.end());
for ( auto _ : state ) {
for ( auto e : v ) {
benchmark::DoNotOptimize(s.find(e.first));
benchmark::DoNotOptimize(s.find(e.second));
}
}
}
template < typename Value >
void std_unordered_map_lookup(benchmark::State& state) {
std::vector<std::pair<int,int>> v;
generate_random_vector(state.range(), v);
std::unordered_map<int, Value> s(v.begin(), v.end());
for ( auto _ : state ) {
for ( auto e : v ) {
benchmark::DoNotOptimize(s.find(e.first));
benchmark::DoNotOptimize(s.find(e.second));
}
}
}
}
BENCHMARK_TEMPLATE(flat_map_lookup, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#ifdef BOOST_CONTAINER_FOUND
BENCHMARK_TEMPLATE(boost_flat_map_lookup, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#endif
BENCHMARK_TEMPLATE(std_map_lookup, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
BENCHMARK_TEMPLATE(std_unordered_map_lookup, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);

View File

@@ -1,94 +0,0 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "bench_base.hpp"
using namespace flat_hpp_unbench;
#include <flat.hpp/flat_set.hpp>
using namespace flat_hpp;
#ifdef BOOST_CONTAINER_FOUND
# include <boost/container/flat_set.hpp>
#endif
namespace
{
template < typename Value >
void flat_set_foreach(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
flat_set<Value> s(v.begin(), v.end());
for ( auto _ : state ) {
int acc = 0;
for ( const auto& e : s ) {
acc += e.x;
}
benchmark::DoNotOptimize(acc);
}
}
#ifdef BOOST_CONTAINER_FOUND
template < typename Value >
void boost_flat_set_foreach(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
boost::container::flat_set<Value> s(v.begin(), v.end());
for ( auto _ : state ) {
int acc = 0;
for ( const auto& e : s ) {
acc += e.x;
}
benchmark::DoNotOptimize(acc);
}
}
#endif
template < typename Value >
void std_set_foreach(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
std::set<Value> s(v.begin(), v.end());
for ( auto _ : state ) {
int acc = 0;
for ( const auto& e : s ) {
acc += e.x;
}
benchmark::DoNotOptimize(acc);
}
}
template < typename Value >
void std_unordered_set_foreach(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
std::unordered_set<Value> s(v.begin(), v.end());
for ( auto _ : state ) {
int acc = 0;
for ( const auto& e : s ) {
acc += e.x;
}
benchmark::DoNotOptimize(acc);
}
}
}
BENCHMARK_TEMPLATE(flat_set_foreach, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#ifdef BOOST_CONTAINER_FOUND
BENCHMARK_TEMPLATE(boost_flat_set_foreach, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#endif
BENCHMARK_TEMPLATE(std_set_foreach, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
BENCHMARK_TEMPLATE(std_unordered_set_foreach, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);

View File

@@ -1,86 +0,0 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "bench_base.hpp"
using namespace flat_hpp_unbench;
#include <flat.hpp/flat_set.hpp>
using namespace flat_hpp;
#ifdef BOOST_CONTAINER_FOUND
# include <boost/container/flat_set.hpp>
#endif
namespace
{
template < typename Key >
void flat_set_insert(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
for ( auto _ : state ) {
flat_set<Key> s;
for ( auto e : v ) {
s.emplace(e);
}
}
}
#ifdef BOOST_CONTAINER_FOUND
template < typename Key >
void boost_flat_set_insert(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
for ( auto _ : state ) {
boost::container::flat_set<Key> s;
for ( auto e : v ) {
s.emplace(e);
}
}
}
#endif
template < typename Key >
void std_set_insert(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
for ( auto _ : state ) {
std::set<Key> s;
for ( auto e : v ) {
s.emplace(e);
}
}
}
template < typename Key >
void std_unordered_set_insert(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
for ( auto _ : state ) {
std::unordered_set<Key> s;
for ( auto e : v ) {
s.emplace(e);
}
}
}
}
BENCHMARK_TEMPLATE(flat_set_insert, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#ifdef BOOST_CONTAINER_FOUND
BENCHMARK_TEMPLATE(boost_flat_set_insert, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#endif
BENCHMARK_TEMPLATE(std_set_insert, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
BENCHMARK_TEMPLATE(std_unordered_set_insert, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);

View File

@@ -1,90 +0,0 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include "bench_base.hpp"
using namespace flat_hpp_unbench;
#include <flat.hpp/flat_set.hpp>
using namespace flat_hpp;
#ifdef BOOST_CONTAINER_FOUND
# include <boost/container/flat_set.hpp>
#endif
namespace
{
template < typename Value >
void flat_set_lookup(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
flat_set<Value> s(v.begin(), v.end());
for ( auto _ : state ) {
for ( auto e : v ) {
benchmark::DoNotOptimize(s.find(e));
benchmark::DoNotOptimize(s.find(e * 2));
}
}
}
#ifdef BOOST_CONTAINER_FOUND
template < typename Value >
void boost_flat_set_lookup(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
boost::container::flat_set<Value> s(v.begin(), v.end());
for ( auto _ : state ) {
for ( auto e : v ) {
benchmark::DoNotOptimize(s.find(e));
benchmark::DoNotOptimize(s.find(e * 2));
}
}
}
#endif
template < typename Value >
void std_set_lookup(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
std::set<Value> s(v.begin(), v.end());
for ( auto _ : state ) {
for ( auto e : v ) {
benchmark::DoNotOptimize(s.find(e));
benchmark::DoNotOptimize(s.find(e * 2));
}
}
}
template < typename Value >
void std_unordered_set_lookup(benchmark::State& state) {
std::vector<int> v;
generate_random_vector(state.range(), v);
std::unordered_set<Value> s(v.begin(), v.end());
for ( auto _ : state ) {
for ( auto e : v ) {
benchmark::DoNotOptimize(s.find(e));
benchmark::DoNotOptimize(s.find(e * 2));
}
}
}
}
BENCHMARK_TEMPLATE(flat_set_lookup, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#ifdef BOOST_CONTAINER_FOUND
BENCHMARK_TEMPLATE(boost_flat_set_lookup, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#endif
BENCHMARK_TEMPLATE(std_set_lookup, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
BENCHMARK_TEMPLATE(std_unordered_set_lookup, vec4)
->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);

17
untests/.clang-tidy Normal file
View File

@@ -0,0 +1,17 @@
---
Checks: '-*,
bugprone-*,
clang-analyzer-*,
concurrency-*,
modernize-*,
-modernize-use-auto,
-modernize-use-trailing-return-type,
-modernize-use-transparent-functors,
portability-*,
'
...

View File

@@ -1,34 +1,67 @@
project(flat.hpp.untests)
#
# coverage
#
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
if(BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"))
set(COVERAGE_FLAGS "--coverage")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
endif()
#
# executable
#
file(GLOB_RECURSE UNTESTS_SOURCES "*.cpp" "*.hpp")
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
target_link_libraries(${PROJECT_NAME} flat.hpp)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${UNTESTS_SOURCES})
target_compile_options(${PROJECT_NAME}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:
/WX /W4>
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:
-Werror -Wall -Wextra -Wpedantic>
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-Werror -Weverything -Wconversion>)
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE flat.hpp)
#
# setup defines
#
function(setup_defines_for_target TARGET)
target_compile_definitions(${TARGET} PRIVATE
DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
DOCTEST_CONFIG_USE_STD_HEADERS)
endfunction()
setup_defines_for_target(${PROJECT_NAME})
#
# setup libraries
#
function(setup_libraries_for_target TARGET)
target_link_libraries(${TARGET} PRIVATE doctest_with_main)
if(${BUILD_WITH_COVERAGE})
target_link_libraries(${TARGET} PRIVATE enable_gcov)
endif()
if(${BUILD_WITH_SANITIZERS})
target_link_libraries(${TARGET} PRIVATE enable_asan enable_ubsan)
endif()
endfunction()
setup_libraries_for_target(${PROJECT_NAME})
#
# setup warnings
#
function(setup_warnings_for_target TARGET)
target_compile_options(${TARGET}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:
/WX /W4>
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:
-Werror -Wall -Wextra -Wpedantic>
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-Werror -Weverything -Wconversion
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-padded
-Wno-unknown-warning-option
>)
endfunction()
setup_warnings_for_target(${PROJECT_NAME})
#
# add tests
#
add_test(${PROJECT_NAME} ${PROJECT_NAME})

View File

@@ -1,2 +0,0 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +0,0 @@
#pragma once
#include "doctest.h"
#define STATIC_REQUIRE(...)\
static_assert(__VA_ARGS__, #__VA_ARGS__);\
REQUIRE(__VA_ARGS__)
#define STATIC_REQUIRE_FALSE(...)\
static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")");\
REQUIRE(!(__VA_ARGS__))

View File

@@ -1,11 +1,11 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat.hpp>
#include "doctest/doctest.hpp"
#include "flat_tests.hpp"
namespace
{

View File

@@ -1,11 +1,11 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat_map.hpp>
#include "doctest/doctest.hpp"
#include "flat_tests.hpp"
#include <deque>
#include <string>
@@ -19,7 +19,7 @@ namespace
class dummy_less {
public:
dummy_less() = default;
dummy_less(int i) noexcept : i(i) {}
dummy_less(int ni) noexcept : i(ni) {}
bool operator()(const T& l, const T& r) const {
return l < r;
}
@@ -369,13 +369,15 @@ TEST_CASE("flat_map") {
}
SUBCASE("access") {
struct obj_t {
obj_t(int i) : i(i) {}
obj_t(int ni) : i(ni) {}
int i;
[[maybe_unused]]
bool operator<(const obj_t& o) const {
return i < o.i;
}
[[maybe_unused]]
bool operator==(const obj_t& o) const {
return i == o.i;
}
@@ -405,13 +407,15 @@ TEST_CASE("flat_map") {
}
SUBCASE("inserts") {
struct obj_t {
obj_t(int i) : i(i) {}
obj_t(int ni) : i(ni) {}
int i;
[[maybe_unused]]
bool operator<(const obj_t& o) const {
return i < o.i;
}
[[maybe_unused]]
bool operator==(const obj_t& o) const {
return i == o.i;
}
@@ -592,7 +596,9 @@ TEST_CASE("flat_map") {
SUBCASE("observers") {
struct my_less {
int i;
my_less(int i) : i(i) {}
my_less(int ni) : i(ni) {}
[[maybe_unused]]
bool operator()(int l, int r) const {
return l < r;
}

View File

@@ -1,11 +1,11 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat_multimap.hpp>
#include "doctest/doctest.hpp"
#include "flat_tests.hpp"
#include <deque>
#include <string>
@@ -19,7 +19,7 @@ namespace
class dummy_less {
public:
dummy_less() = default;
dummy_less(int i) noexcept : i(i) {}
dummy_less(int ni) noexcept : i(ni) {}
bool operator()(const T& l, const T& r) const {
return l < r;
}
@@ -369,13 +369,15 @@ TEST_CASE("flat_multimap") {
}
SUBCASE("access") {
struct obj_t {
obj_t(int i) : i(i) {}
obj_t(int ni) : i(ni) {}
int i;
[[maybe_unused]]
bool operator<(const obj_t& o) const {
return i < o.i;
}
[[maybe_unused]]
bool operator==(const obj_t& o) const {
return i == o.i;
}
@@ -405,13 +407,15 @@ TEST_CASE("flat_multimap") {
}
SUBCASE("inserts") {
struct obj_t {
obj_t(int i) : i(i) {}
obj_t(int ni) : i(ni) {}
int i;
[[maybe_unused]]
bool operator<(const obj_t& o) const {
return i < o.i;
}
[[maybe_unused]]
bool operator==(const obj_t& o) const {
return i == o.i;
}
@@ -566,7 +570,9 @@ TEST_CASE("flat_multimap") {
SUBCASE("observers") {
struct my_less {
int i;
my_less(int i) : i(i) {}
my_less(int ni) : i(ni) {}
[[maybe_unused]]
bool operator()(int l, int r) const {
return l < r;
}

View File

@@ -1,11 +1,11 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat_multiset.hpp>
#include "doctest/doctest.hpp"
#include "flat_tests.hpp"
#include <deque>
#include <string>
@@ -19,7 +19,7 @@ namespace
class dummy_less {
public:
dummy_less() = default;
dummy_less(int i) noexcept : i(i) {}
dummy_less(int ni) noexcept : i(ni) {}
bool operator()(const T& l, const T& r) const {
return l < r;
}
@@ -324,13 +324,15 @@ TEST_CASE("flat_multiset") {
}
SUBCASE("inserts") {
struct obj_t {
obj_t(int i) : i(i) {}
obj_t(int ni) : i(ni) {}
int i;
[[maybe_unused]]
bool operator<(const obj_t& o) const {
return i < o.i;
}
[[maybe_unused]]
bool operator==(const obj_t& o) const {
return i == o.i;
}
@@ -510,7 +512,7 @@ TEST_CASE("flat_multiset") {
SUBCASE("observers") {
struct my_less {
int i;
my_less(int i) : i(i) {}
my_less(int ni) : i(ni) {}
[[maybe_unused]] bool operator()(int l, int r) const {
return l < r;
}

View File

@@ -1,11 +1,11 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2021, by Matvey Cherevko (blackmatov@gmail.com)
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <flat.hpp/flat_set.hpp>
#include "doctest/doctest.hpp"
#include "flat_tests.hpp"
#include <deque>
#include <string>
@@ -19,7 +19,7 @@ namespace
class dummy_less {
public:
dummy_less() = default;
dummy_less(int i) noexcept : i(i) {}
dummy_less(int ni) noexcept : i(ni) {}
bool operator()(const T& l, const T& r) const {
return l < r;
}
@@ -324,13 +324,15 @@ TEST_CASE("flat_set") {
}
SUBCASE("inserts") {
struct obj_t {
obj_t(int i) : i(i) {}
obj_t(int ni) : i(ni) {}
int i;
[[maybe_unused]]
bool operator<(const obj_t& o) const {
return i < o.i;
}
[[maybe_unused]]
bool operator==(const obj_t& o) const {
return i == o.i;
}
@@ -508,7 +510,7 @@ TEST_CASE("flat_set") {
SUBCASE("observers") {
struct my_less {
int i;
my_less(int i) : i(i) {}
my_less(int ni) : i(ni) {}
[[maybe_unused]] bool operator()(int l, int r) const {
return l < r;
}

15
untests/flat_tests.hpp Normal file
View File

@@ -0,0 +1,15 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/flat.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <doctest/doctest.h>
#define STATIC_REQUIRE(...)\
static_assert(__VA_ARGS__, #__VA_ARGS__);\
REQUIRE(__VA_ARGS__)
#define STATIC_REQUIRE_FALSE(...)\
static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")");\
REQUIRE(!(__VA_ARGS__))

5
vendors/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,5 @@
project(flat.hpp.vendors)
set(DOCTEST_NO_INSTALL ON CACHE INTERNAL "")
add_subdirectory(doctest)
set_target_properties(doctest_with_main PROPERTIES FOLDER flat.hpp.vendors)

1
vendors/doctest vendored Submodule

Submodule vendors/doctest added at b7c21ec5ce