Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Twon committed Nov 8, 2023
2 parents 2760e88 + dd141a7 commit 117f729
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 66 deletions.
17 changes: 8 additions & 9 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
Expand Down Expand Up @@ -60,12 +60,12 @@ DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Expand Down Expand Up @@ -99,9 +99,9 @@ PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
RawStringFormats:
- Language: Cpp
Delimiters:
Delimiters:
- cc
- CC
- cpp
Expand All @@ -112,12 +112,12 @@ RawStringFormats:
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
Expand Down Expand Up @@ -147,10 +147,9 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
StatementMacros:
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
...

17 changes: 17 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Dockerfile for Ubuntu 22.04 with C++ development tools.

# Set the base image.
FROM ubuntu:22.04

# Install gcc, clang and some supporting tools for downloading/installing later tools.
RUN apt-get update && apt-get install -y wget g++ lcov llvm git gpg ninja-build software-properties-common unzip

# Install newer CMake from kitware.
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null \
&& apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ jammy main' && apt-get update && apt-get install -y cmake

# Install bazel.
RUN wget https://github.com/bazelbuild/bazel/releases/download/6.4.0/bazel-6.4.0-installer-linux-x86_64.sh \
&& bash bazel-6.4.0-installer-linux-x86_64.sh && rm bazel-6.4.0-installer-linux-x86_64.sh

ENV PATH="/usr/local/bin:$PATH"
6 changes: 6 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "C++",
"build": {
"dockerfile": "Dockerfile"
},
}
10 changes: 5 additions & 5 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ jobs:
matrix:
settings:
- {
name: "debug",
name: "Bazel test: debug",
flags: "-c dbg",
}
- {
name: "optimized",
name: "Bazel test: optimized",
flags: "-c opt",
}
- {
name: "address sanitizer",
name: "Bazel test: address sanitizer",
flags: "--config=asan",
}
- {
name: "undefined behaviour sanitizer",
name: "Bazel test: undefined behaviour sanitizer",
flags: "--config=ubsan",
}
- {
name: "thread sanitizer",
name: "Bazel test: thread sanitizer",
flags: "--config=tsan",
}
steps:
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/integrity_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Integrity Checks

on:
push:
branches: [main]
pull_request:
branches: [main]

defaults:
run:
shell: bash

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Install action-validator with asdf
uses: asdf-vm/actions/install@v2
with:
tool_versions: |
action-validator 0.5.1
- name: Lint Actions
run: |
find .github/workflows -type f \( -iname \*.yaml -o -iname \*.yml \) \
| xargs -I {} action-validator --verbose {}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
.venv/
.vs/
.vscode/
_build
Expand Down
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .pre-commit-config.yaml
# ========================
#
# pre-commit clean
# pre-commit install
# pre-commit install-hooks
#
# precommit hooks installation
#
# - pre-commit autoupdate
#
# - pre-commit run black
#
# continuous integration
# ======================
#
# - pre-commit run --all-files
#
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: forbid-submodules
- id: requirements-txt-fixer
- id: trailing-whitespace
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ target_compile_features(polymorphic_inline_vtable
INTERFACE
cxx_std_23
)
target_compile_definitions(polymorphic_inline_vtable
INTERFACE
target_compile_definitions(polymorphic_inline_vtable
INTERFACE
XYZ_POLYMORPHIC_USES_EXPERIMENTAL_INLINE_VTABLE
)

Expand All @@ -104,8 +104,8 @@ target_compile_features(polymorphic_sbo
INTERFACE
cxx_std_23
)
target_compile_definitions(polymorphic_sbo
INTERFACE
target_compile_definitions(polymorphic_sbo
INTERFACE
XYZ_POLYMORPHIC_USES_EXPERIMENTAL_SMALL_BUFFER_OPTIMIZATION
)

Expand Down Expand Up @@ -143,7 +143,7 @@ if (${CPP_VALUE_TYPES_IS_NOT_SUBPROJECT})
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)

add_executable(indirect_test "")
target_sources(indirect_test
PRIVATE
Expand Down Expand Up @@ -187,7 +187,7 @@ if (${CPP_VALUE_TYPES_IS_NOT_SUBPROJECT})
)
target_compile_options(polymorphic_sbo_test
PRIVATE
$<$<CXX_COMPILER_ID:Clang>:-ftemplate-backtrace-limit=0>
$<$<CXX_COMPILER_ID:Clang>:-ftemplate-backtrace-limit=0>
)
target_link_libraries(polymorphic_sbo_test
PRIVATE
Expand Down
4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
@jbcoe
@twon

# CMake
# CMake
CMakeLists.txt @twon

# Bazel
# Bazel
*.bazel @jbcoe
28 changes: 12 additions & 16 deletions DRAFT.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct A {

class Composite {
indirect<A> a_;

Constness foo() { return a_.foo(); }
Constness foo() const { return a_.foo(); };
};
Expand Down Expand Up @@ -268,7 +268,7 @@ The template parameter `T` of `indirect` may be an incomplete type.
template <class T, class Allocator = std::allocator<T>>
class indirect {
T* p_; // exposition only
Allocator allocator_; // exposition only
Allocator allocator_; // exposition only
public:
using value_type = T;
using allocator_type = Allocator;
Expand All @@ -288,7 +288,7 @@ class indirect {
std::allocator_arg_t, const Allocator& alloc, const indirect& other);
constexpr indirect(indirect&& other) noexcept;
constexpr indirect(
std::allocator_arg_t, const Allocator& alloc, indirect&& other) noexcept;
Expand Down Expand Up @@ -665,7 +665,7 @@ constexpr auto operator<=>(const U& lhs, const indirect<T, A>& rhs);
* _Preconditions_: Alloc meets the _Cpp17Allocator_ requirements.
#### X.Y.10 Hash support [indirect.hash]
```c++
template <class T, class Alloc>
struct std::hash<indirect<T, Alloc>>;
Expand Down Expand Up @@ -756,7 +756,7 @@ The template parameter `T` of `polymorphic` may be an incomplete type.
template <class T, class Allocator = std::allocator<T>>
class polymorphic {
control_block* control_block_; // exposition only
Allocator allocator_; // exposition only
Allocator allocator_; // exposition only
public:
using value_type = T;
using allocator_type = Allocator;
Expand All @@ -771,12 +771,12 @@ class polymorphic {
std::allocator_arg_t, const Allocator& alloc, std::in_place_type_t<U>, Ts&&... ts);

constexpr polymorphic(const polymorphic& other);

constexpr polymorphic(
std::allocator_arg_t, const Allocator& alloc, const polymorphic& other);

constexpr polymorphic(polymorphic&& other) noexcept;

constexpr polymorphic(
std::allocator_arg_t, const Allocator& alloc, polymorphic&& other) noexcept;

Expand Down Expand Up @@ -972,7 +972,7 @@ constexpr allocator_type get_allocator() const noexcept;
* _Returns_: A copy of the Allocator object used to construct the owned object
or, if that allocator has been replaced, a copy of the most recent
replacement.

#### X.Z.7 Swap [polymorphic.swap]

```c++
Expand Down Expand Up @@ -1029,11 +1029,7 @@ Otherwise, the interface of the specialization is as defined in [optional].
Add a new feature-test macro:

```c++
<<<<<<< HEAD
#define __cpp_lib_polymorphic 2023XXL
=======
#define __cpp_lib_value_types 2023XXL
>>>>>>> 5ccaf0258047213454eaec39d2a1fcc9cfe83dd6
#define __cpp_lib_value_types 2023XXL
```
## Reference implementation
Expand Down Expand Up @@ -1245,7 +1241,7 @@ class Class {
Class& operator=(const Class&);
Class(Class&&) noexcept;
Class& operator=(Class&&) noexcept;

void do_something();
};
```
Expand Down Expand Up @@ -1295,7 +1291,7 @@ class Class {
Class& operator=(const Class&);
Class(Class&&) noexcept;
Class& operator=(Class&&) noexcept;

void do_something();
};
```
Expand Down Expand Up @@ -1372,7 +1368,7 @@ class Picture {
```
#### After, using `polymorphic`
```c++
class Canvas;
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class Composite {
xyz::indirect<A> a_; // a_ owns an object of type A
xyz::indirect<B> b_; // b_ owns an object of type B
public:
Composite(const A& a, const B& b) :
a_(std::in_place, a),
Composite(const A& a, const B& b) :
a_(std::in_place, a),
b_(std::in_place, b) {}

// ...
Expand All @@ -69,8 +69,8 @@ class CompositeWithPolymorphicMembers {
xyz::polymorphic<Y> y_; // y_ owns an object of type Y or derived from Y
public:
template <typename Tx, typename Ty>
Composite(const Tx& x, const Ty& y) :
a_(std::in_place_type<Tx>, x),
Composite(const Tx& x, const Ty& y) :
a_(std::in_place_type<Tx>, x),
b_(std::in_place_type<Ty>, y) {}
// ...
Expand All @@ -94,12 +94,16 @@ This code is licensed under the MIT License. See [LICENSE](LICENSE) for details.
## Talks and presentations

We spoke about an earlier draft at [C++ on
Sea](https://www.youtube.com/watch?v=sjLRX4WMvlU) in 2022.
Sea](https://www.youtube.com/watch?v=sjLRX4WMvlU) in 2022.

There are some significant design changes since this talk was given (after feedback
and discussion at a C++ London meetup). We've pared down the number of constructors
There are some significant design changes since this talk was given (after feedback
and discussion at a C++ London meetup). We've pared down the number of constructors
and made the null state unobservable.

## Developer Guide

For building and working with the project, please see the [developer guide](docs/developer-guide.md).

## References

* [TK's allocator user guide]
Expand Down
Loading

0 comments on commit 117f729

Please sign in to comment.