Skip to content

Commit 28d3eb7

Browse files
committed
Add initial version of the code.
1 parent 3c1520b commit 28d3eb7

File tree

11 files changed

+292
-0
lines changed

11 files changed

+292
-0
lines changed

.clang-format

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: LLVM
4+
AccessModifierOffset: -4
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignOperands: false
8+
AlignTrailingComments: false
9+
AlwaysBreakTemplateDeclarations: Yes
10+
BraceWrapping:
11+
AfterCaseLabel: true
12+
AfterClass: true
13+
AfterControlStatement: true
14+
AfterEnum: true
15+
AfterFunction: true
16+
AfterNamespace: true
17+
AfterStruct: true
18+
AfterUnion: true
19+
AfterExternBlock: false
20+
BeforeCatch: true
21+
BeforeElse: true
22+
BeforeLambdaBody: true
23+
BeforeWhile: true
24+
SplitEmptyFunction: true
25+
SplitEmptyRecord: true
26+
SplitEmptyNamespace: true
27+
BreakBeforeBraces: Custom
28+
BreakConstructorInitializers: AfterColon
29+
BreakConstructorInitializersBeforeComma: false
30+
ColumnLimit: 120
31+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
32+
IncludeCategories:
33+
- Regex: '^<.*'
34+
Priority: 1
35+
- Regex: '^".*'
36+
Priority: 2
37+
- Regex: '.*'
38+
Priority: 3
39+
IncludeIsMainRegex: '([-_](test|unittest))?$'
40+
IndentCaseBlocks: true
41+
IndentWidth: 4
42+
InsertNewlineAtEOF: true
43+
MacroBlockBegin: ''
44+
MacroBlockEnd: ''
45+
MaxEmptyLinesToKeep: 2
46+
NamespaceIndentation: All
47+
PointerAlignment: Left
48+
SpaceInEmptyParentheses: false
49+
SpacesInAngles: false
50+
SpacesInConditionalStatement: false
51+
SpacesInCStyleCastParentheses: false
52+
SpacesInParentheses: false
53+
TabWidth: 4
54+
...

.clang-tidy

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
Checks: "*,
3+
-abseil-*,
4+
-altera-*,
5+
-android-*,
6+
-fuchsia-*,
7+
-google-*,
8+
-llvm*,
9+
-modernize-use-trailing-return-type,
10+
-zircon-*,
11+
-readability-else-after-return,
12+
-readability-static-accessed-through-instance,
13+
-readability-avoid-const-params-in-decls,
14+
-cppcoreguidelines-non-private-member-variables-in-classes,
15+
-misc-non-private-member-variables-in-classes,
16+
-misc-no-recursion,
17+
-misc-use-anonymous-namespace,
18+
-misc-use-internal-linkage
19+
"
20+
WarningsAsErrors: ''
21+
HeaderFilterRegex: ''
22+
FormatStyle: none
23+
24+
CheckOptions:
25+
- key: readability-identifier-length.IgnoredVariableNames
26+
value: 'x|y|z'
27+
- key: readability-identifier-length.IgnoredParameterNames
28+
value: 'x|y|z'

.devcontainer/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
2+
3+
# Install additional packages if needed
4+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5+
&& apt-get -y install --no-install-recommends \
6+
lsb-release \
7+
wget \
8+
software-properties-common \
9+
gnupg
10+
11+
# Install Clang 20 using the official script
12+
# We use 'all' to ensure we get clang-scan-deps and other tools
13+
RUN wget https://apt.llvm.org/llvm.sh && \
14+
chmod +x llvm.sh && \
15+
./llvm.sh 20 all && \
16+
rm llvm.sh
17+
18+
# Install libc++ for Clang 20 explicitly to ensure full C++23 support if needed
19+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
20+
&& apt-get -y install --no-install-recommends \
21+
libc++-20-dev \
22+
libc++abi-20-dev
23+
24+
# Set up update-alternatives to make clang-20 the default
25+
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 200 && \
26+
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 200 && \
27+
update-alternatives --install /usr/bin/clang-scan-deps clang-scan-deps /usr/bin/clang-scan-deps-20 200 && \
28+
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-20 200 && \
29+
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-20 200 && \
30+
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-20 200

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "C++",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {
7+
"ghcr.io/devcontainers/features/common-utils:2": {
8+
"installZsh": true,
9+
"configureZshAsDefaultShell": true,
10+
"installOhMyZsh": true,
11+
"upgradePackages": true
12+
}
13+
},
14+
"customizations": {
15+
"vscode": {
16+
"extensions": [
17+
"ms-vscode.cpptools",
18+
"ms-vscode.cmake-tools",
19+
"llvm-vs-code-extensions.vscode-clangd",
20+
"vadimcn.vscode-lldb"
21+
],
22+
"settings": {
23+
"cmake.configureOnOpen": true,
24+
"clangd.path": "/usr/bin/clangd",
25+
"C_Cpp.intelliSenseEngine": "disabled"
26+
}
27+
}
28+
},
29+
"postCreateCommand": "clang++ --version && clang-scan-deps --version"
30+
}

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: C++ CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-test:
11+
name: ${{ matrix.compiler.name }}
12+
runs-on: ubuntu-24.04
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
compiler:
17+
- name: GCC 14
18+
cc: gcc-14
19+
cxx: g++-14
20+
install_script: |
21+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
22+
sudo apt-get update
23+
sudo apt-get install -y gcc-14 g++-14
24+
- name: Clang 20
25+
cc: clang-20
26+
cxx: clang++-20
27+
install_script: |
28+
wget https://apt.llvm.org/llvm.sh
29+
chmod +x llvm.sh
30+
sudo ./llvm.sh 20 all
31+
sudo apt-get install -y libc++-20-dev libc++abi-20-dev
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
# - name: Install Build Tools
37+
# run: |
38+
# sudo apt-get update
39+
# sudo apt-get install -y ninja-build cmake
40+
41+
- name: Install Compiler
42+
run: ${{ matrix.compiler.install_script }}
43+
44+
- name: Configure CMake
45+
env:
46+
CC: ${{ matrix.compiler.cc }}
47+
CXX: ${{ matrix.compiler.cxx }}
48+
run: |
49+
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
50+
51+
- name: Build
52+
run: cmake --build build
53+
54+
- name: Test
55+
run: ctest --test-dir build --output-on-failure

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmake-build-debug
2+
.idea
3+
.build
4+
build
5+
.cache

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"clangd.arguments": [
3+
"--compile-commands-dir=${workspaceFolder}/build",
4+
"--background-index",
5+
"--clang-tidy",
6+
"--completion-style=detailed",
7+
"--header-insertion=iwyu",
8+
"--query-driver=/usr/bin/clang++"
9+
]
10+
}

CMakeLists.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
cmake_minimum_required(VERSION 3.28)
2+
project(positionless_cpp)
3+
4+
set(CMAKE_CXX_STANDARD 23)
5+
6+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
7+
add_compile_options(-stdlib=libc++)
8+
add_link_options(-stdlib=libc++)
9+
endif()
10+
11+
# Setup CPM
12+
file(DOWNLOAD
13+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.2/CPM.cmake
14+
${CMAKE_BINARY_DIR}/cmake/CPM.cmake
15+
EXPECTED_HASH SHA256=c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d
16+
)
17+
include(${CMAKE_BINARY_DIR}/cmake/CPM.cmake)
18+
19+
# Add doctest
20+
CPMAddPackage(
21+
NAME doctest
22+
GITHUB_REPOSITORY doctest/doctest
23+
VERSION 2.4.12
24+
)
25+
26+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
27+
28+
add_library(positionless INTERFACE)
29+
target_include_directories(positionless INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
30+
target_compile_options(positionless INTERFACE
31+
$<$<CXX_COMPILER_ID:Clang,AppleClang,GNU>:-Wall -Wextra -Wpedantic>
32+
$<$<CXX_COMPILER_ID:MSVC>:/W4>
33+
)
34+
35+
add_executable(unit_tests test/partitioning_tests.cpp)
36+
target_link_libraries(unit_tests PRIVATE positionless doctest::doctest)
37+
target_compile_options(unit_tests PRIVATE
38+
$<$<CXX_COMPILER_ID:Clang,AppleClang,GNU>:-Wall -Wextra -Wpedantic>
39+
$<$<CXX_COMPILER_ID:MSVC>:/W4>
40+
)
41+
42+
enable_testing()
43+
add_test(NAME unit_tests COMMAND unit_tests)

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Postionless algorithms -- C++ prototypes
2+
3+
We want to have an implementation of positionless algorithms and a translation from C++ iterators to positionless, so that we can use positionless with STL algorithms.
4+
5+
6+
## Positionless features
7+
TODO
8+
9+
## Translation from iterators
10+
TODO
11+
12+
## Building & testing
13+
```
14+
cmake -D CMAKE_BUILD_TYPE=Release -G Ninja -S . -B .build
15+
cmake --build .build
16+
ctest --test-dir .build
17+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
namespace positionless
4+
{
5+
6+
template <typename Iterator>
7+
struct partitioning
8+
{
9+
Iterator begin;
10+
Iterator end;
11+
// TODO
12+
};
13+
14+
} // namespace positionless

0 commit comments

Comments
 (0)