diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 91346af..a3d5aa9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,11 +5,13 @@ jobs: steps: - checkout: self submodules: true - - script: - docker run -v${PWD}:/build - arbmind/qbs-clang7:1 - build --file /build/BasiC++17.qbs --build-directory /tmp/build - -p autotest-runner + - task: ShellScript@2 + inputs: + scriptPath: thirdparty/git_clone_googletest.sh + - script: docker run -v${PWD}:/build + arbmind/qbs-clang7:1 + build --file /build/BasiC++17.qbs --build-directory /tmp/build + -p autotest-runner - job: Windows pool: @@ -21,6 +23,9 @@ jobs: - script: qbs config --list profiles - checkout: self submodules: true + - task: ShellScript@2 + inputs: + scriptPath: thirdparty/git_clone_googletest.sh - script: qbs - build profile:MSVC2019-x64 --file BasiC++17.qbs --build-directory %TMP%\build - -p autotest-runner + build profile:MSVC2019-x64 --file BasiC++17.qbs --build-directory %TMP%\build + -p autotest-runner diff --git a/src/meta17.lib/meta17/IndexPack.iterate.h b/src/meta17.lib/meta17/IndexPack.iterate.h new file mode 100644 index 0000000..b1a14ff --- /dev/null +++ b/src/meta17.lib/meta17/IndexPack.iterate.h @@ -0,0 +1,13 @@ +#pragma once +#include "Index.h" +#include "IndexPack.h" + +namespace meta17 { + +/// "constexpr for": Iterate over a sequence with compile-time available indices +template +constexpr auto forEachIndex(IndexPack, Callable&& callable) { + return (..., callable(_index)); +} + +} // namespace meta17 diff --git a/src/meta17.lib/meta17/IndexPack.iterate.test.cpp b/src/meta17.lib/meta17/IndexPack.iterate.test.cpp new file mode 100644 index 0000000..7f18a63 --- /dev/null +++ b/src/meta17.lib/meta17/IndexPack.iterate.test.cpp @@ -0,0 +1,11 @@ +#include "IndexPack.iterate.h" + +#include "Index.wrap.h" // UnwrapType +#include + +using namespace meta17; + +static_assert(forEachIndex(index_pack<12, 23>, [s = 0](auto i) mutable { + s += to_value; + return s; + }) == 35); diff --git a/src/meta17.lib/meta17/meta17.qbs b/src/meta17.lib/meta17/meta17.qbs index 68193d9..c9d8221 100644 --- a/src/meta17.lib/meta17/meta17.qbs +++ b/src/meta17.lib/meta17/meta17.qbs @@ -50,6 +50,7 @@ Product { "IndexPack.extract.h", "IndexPack.for.h", "IndexPack.h", + "IndexPack.iterate.h", "IndexPack.make.h", "IndexPack.ops.h", "IndexPack.trait.h", @@ -152,6 +153,7 @@ Product { "Unreachable.h", "align.h", "same.h", + "ptr.h", ] Export { diff --git a/src/meta17.lib/meta17/meta17.tests.qbs b/src/meta17.lib/meta17/meta17.tests.qbs index 3b198f8..c0da832 100644 --- a/src/meta17.lib/meta17/meta17.tests.qbs +++ b/src/meta17.lib/meta17/meta17.tests.qbs @@ -53,6 +53,7 @@ Application { files: [ "IndexPack.extract.test.cpp", "IndexPack.for.test.cpp", + "IndexPack.iterate.test.cpp", "IndexPack.make.test.cpp", "IndexPack.ops.test.cpp", "IndexPack.test.cpp", @@ -150,5 +151,6 @@ Application { "StaticErrorExpr.test.cpp", "align.test.cpp", "main.cpp", + "ptr.test.cpp", ] } diff --git a/src/meta17.lib/meta17/ptr.h b/src/meta17.lib/meta17/ptr.h new file mode 100644 index 0000000..fd42184 --- /dev/null +++ b/src/meta17.lib/meta17/ptr.h @@ -0,0 +1,8 @@ +#pragma once + +namespace meta17 { + +template +constexpr T* nullptr_to = nullptr; + +} diff --git a/src/meta17.lib/meta17/ptr.test.cpp b/src/meta17.lib/meta17/ptr.test.cpp new file mode 100644 index 0000000..0a6dfb8 --- /dev/null +++ b/src/meta17.lib/meta17/ptr.test.cpp @@ -0,0 +1,7 @@ +#include "ptr.h" +#include "same.h" + +using namespace meta17; + +static_assert(same), int* const>); +static_assert(nullptr_to == nullptr); diff --git a/src/strong17.lib/strong17/Strong.opaque.h b/src/strong17.lib/strong17/Strong.opaque.h index 5156e44..e80f7de 100644 --- a/src/strong17.lib/strong17/Strong.opaque.h +++ b/src/strong17.lib/strong17/Strong.opaque.h @@ -4,8 +4,6 @@ #include "Strong.make.h" #include "meta17/Type.h" -#include "meta17/TypePack.h" -#include "meta17/TypePack.recurse.h" #define STRONG_OPAQUE(NAME, TYPE, ...) \ struct NAME; \ diff --git a/src/strong17.lib/strong17/Strong.opaque.test.cpp b/src/strong17.lib/strong17/Strong.opaque.test.cpp new file mode 100644 index 0000000..a45549e --- /dev/null +++ b/src/strong17.lib/strong17/Strong.opaque.test.cpp @@ -0,0 +1,19 @@ +#include "Strong.opaque.h" + +#include + +namespace testing { + +STRONG_OPAQUE(HelloTest, int, struct HelloTag); + +} // namespace testing + +STRONG_OPAQUE(HelloGlobal, int, struct HelloTag); + +TEST(Strong, opaque) { + constexpr auto ht = testing::HelloTest{15}; + static_assert(ht.v == 15); + + constexpr auto hg = HelloGlobal{23}; + static_assert(hg.v == 23); +} diff --git a/src/strong17.lib/strong17/Strong.trait.h b/src/strong17.lib/strong17/Strong.trait.h index 26bfe1a..e297591 100644 --- a/src/strong17.lib/strong17/Strong.trait.h +++ b/src/strong17.lib/strong17/Strong.trait.h @@ -12,14 +12,11 @@ using meta17::False; using meta17::is_type_template; using meta17::same; -template -struct IsStrong : False {}; - -template -struct IsStrong>> : Bool, Strong>> {}; +template +constexpr auto is_strong = false; template -constexpr auto is_strong = IsStrong>{}; +constexpr auto is_strong>> = is_type_template, Strong>; template struct IsOpaque : False {}; diff --git a/src/strong17.lib/strong17/Strong.weaken.h b/src/strong17.lib/strong17/Strong.weaken.h index 2e64f45..64f44c7 100644 --- a/src/strong17.lib/strong17/Strong.weaken.h +++ b/src/strong17.lib/strong17/Strong.weaken.h @@ -18,11 +18,11 @@ using meta17::UnwrapType; /// like extractValue, but does nothing for non-strong types template -constexpr auto weakenType(Type = {}) -> std::enable_if_t.v, Type>>> { +constexpr auto weakenType(Type = {}) -> std::enable_if_t, Type>>> { return {}; } template -constexpr auto weakenType(Type = {}) -> std::enable_if_t.v, Type> { +constexpr auto weakenType(Type = {}) -> std::enable_if_t, Type> { return {}; } template diff --git a/src/strong17.lib/strong17/strong17.tests.qbs b/src/strong17.lib/strong17/strong17.tests.qbs index 181c003..688cd11 100644 --- a/src/strong17.lib/strong17/strong17.tests.qbs +++ b/src/strong17.lib/strong17/strong17.tests.qbs @@ -16,6 +16,7 @@ Application { "Strong.inspect.test.cpp", "Strong.make.test.cpp", "Strong.manip.test.cpp", + "Strong.opaque.test.cpp", "Strong.ops.test.cpp", "Strong.ostream.cpp", "Strong.test.cpp",