Git Product home page Git Product logo

tuplet's Introduction

Hi! My name is Alecto! Welcome to my github!

Iโ€™m currently working on a number of projects. These range from projects in C++ with ambitious scopes, to more down-to-earth projects. I'm currently a student, and a few of the projects here are projects for some of my courses.

There are a few projects in particular that I'm looking to collaborate on! These are:

  • Noam, a parser combinator library, and
  • Conduit, a library for coroutines in C++ 20,

Both of these are at the stage where I feel that other people can start using and experimenting with them, and I'd love for you to take a look at them!

Reaching Out

I'm availible on twitter and via email if you'd like to get in touch, or if there's any improvements you see to any of my projects, feel free to submit a pull request with your work!

Stats and Numbers

Alecto's GitHub stats

Top Langs

tuplet's People

Contributors

bugwelle avatar c4v4 avatar codeinred avatar lukester1975 avatar nn--- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tuplet's Issues

Empty tuple not supported

Hi,

first of all: Great library! I've learned a few C++ tricks here and there while reading the code.

I wanted to try this library as a replacement for std::tuple in my code base to check if it improves (compile) performance. Unfortunately, there are a few minor to major differences to std::tuple that make it difficult to use it as a drop-in replacement.

One case I heavily rely on in my code base is the use of empty tuples.

Example:

See https://godbolt.org/z/ojYM79q3K

tuplet::tuple<> empty_fails;

Motivation

I've written some generic code that stores lambdas in tuples.
And I've got some code that can append other lambdas to this tuple (and a new tuple is returned).
Because it's quite generic, it may happen that one tuple is empty.

How to fix

A quick&dirty fix I've used is to add something like this:

template<>
struct tuple<> {
    constexpr static size_t N = 0;

    template <other_than<tuple> U> 
    constexpr auto& operator=(U&& tup)
    {
        // We can't really assign empty tuples, can we?
        return *this;
    }

    template <typename... U>
    constexpr auto& assign(U&&... )
    {
        // Also not really needed.
        return *this;
    }
};

Assignment broken with msvc once again

Accidental (?) reversion of the fix from #21 by the looks of it in 875c5de:

(void(B1::value = static_cast<U&&>(u).B2::value), ...);
was changed back to:
(void(B1::value = static_cast<U&&>(u).identity_t<B2>::value), ...);

Remove identity_t and all is well again, but maybe a better fix is needed if that identity_t is really there for a reason!

Also it appears to manifest only in c++20 mode. At least the tests all compile and work by default, but that seems to be in c++17 mode. Trying to configure cmake with -DCXX_STANDARD=20 caused all sorts of std::format weirdness. I don't really have the time to look in to that; I'm just going to apply the old fix locally as it was working fine but here's a simple test instead:

#include <cassert>
#include <tuplet/tuple.hpp>

int main()
{
	int a = -1;
	tuplet::tie(a) = tuplet::make_tuple(123);
	assert(a == 123);
}

With c++20:

 cl test.cpp /std:c++20 -I./include && ./test.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31937 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
Microsoft (R) Incremental Linker Version 14.34.31937.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj
Assertion failed: a == 123, file test.cpp, line 8

And 17:

 cl test.cpp /std:c++17 -I./include && ./test.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31937 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
Microsoft (R) Incremental Linker Version 14.34.31937.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:test.exe
test.obj

Sadly no movement at all in https://developercommunity.visualstudio.com/t/fold-expressions-unreliable-in-171-with-c20/1676476

Thanks!

Please add the possibility to install the library

It would be great if your library provided some tuplet-config.cmake file so that users only have to call
find_package(tuplet <some version> REQUIRED) in their CMakeLists.txt to be able to find your library, rather that copying and pasting the 'tuplet/tuple.hpp' file.

Anyway, thank you for your work.

add various compiler result?

msvc 19.29.30133

2021-09-29T19:13:28+07:00
Running bench
Run on (4 X 3696 MHz CPU s)
CPU Caches:
L1 Data 32 KiB (x2)
L1 Instruction 32 KiB (x2)
L2 Unified 256 KiB (x2)
L3 Unified 3072 KiB (x1)

----------------------------------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------------------------------
BM_copy/single_elem_std_tuple_v4 6.54 ns 6.56 ns 112000000
BM_copy/single_elem_tuplet_tuple_v4 5.20 ns 5.16 ns 154482759
BM_copy/single_elem_std_tuple_v8 8.69 ns 8.72 ns 89600000
BM_copy/single_elem_tuplet_tuple_v8 7.19 ns 7.15 ns 89600000
BM_copy/single_elem_std_tuple_v16 14.8 ns 15.1 ns 53952688
BM_copy/single_elem_tuplet_tuple_v16 7.65 ns 7.67 ns 89600000
BM_copy/single_elem_std_tuple_v32 21.8 ns 21.5 ns 32000000
BM_copy/single_elem_tuplet_tuple_v32 12.6 ns 12.6 ns 89600000
BM_copy/single_elem_std_tuple_v64 39.1 ns 39.2 ns 17920000
BM_copy/single_elem_tuplet_tuple_v64 9.30 ns 9.42 ns 74666667
BM_copy/single_elem_std_tuple_v128 80.8 ns 80.2 ns 8960000
BM_copy/single_elem_tuplet_tuple_v128 13.4 ns 13.5 ns 49777778
BM_copy/single_elem_std_tuple_v256 151 ns 151 ns 4977778
BM_copy/single_elem_tuplet_tuple_v256 20.4 ns 20.4 ns 34461538
BM_copy/single_elem_std_tuple_v512 291 ns 292 ns 2357895
BM_copy/single_elem_tuplet_tuple_v512 38.4 ns 38.5 ns 18666667
BM_copy/single_elem_std_tuple_v1024 569 ns 578 ns 1000000
BM_copy/single_elem_tuplet_tuple_v1024 76.7 ns 76.7 ns 8960000
BM_copy/homogenous_std_tuple_v4 10.6 ns 10.5 ns 64000000
BM_copy/homogenous_tuplet_tuple_v4 4.30 ns 4.33 ns 165925926
BM_copy/homogenous_std_tuple_v8 19.3 ns 19.0 ns 34461538
BM_copy/homogenous_tuplet_tuple_v8 6.21 ns 6.28 ns 112000000
BM_copy/homogenous_std_tuple_v16 36.7 ns 36.8 ns 18666667
BM_copy/homogenous_tuplet_tuple_v16 6.67 ns 6.63 ns 89600000
BM_copy/homogenous_std_tuple_v32 71.6 ns 71.5 ns 8960000
BM_copy/homogenous_tuplet_tuple_v32 12.6 ns 12.6 ns 56000000
BM_copy/homogenous_std_tuple_v64 142 ns 141 ns 4977778
BM_copy/homogenous_tuplet_tuple_v64 9.67 ns 9.63 ns 74666667
BM_copy/homogenous_std_tuple_v128 282 ns 283 ns 2488889
BM_copy/homogenous_tuplet_tuple_v128 13.3 ns 13.2 ns 49777778
BM_copy/homogenous_std_tuple_v256 562 ns 558 ns 1120000
BM_copy/homogenous_tuplet_tuple_v256 21.1 ns 21.3 ns 34461538
BM_copy/homogenous_std_tuple_v512 1119 ns 1123 ns 640000
BM_copy/homogenous_tuplet_tuple_v512 38.2 ns 38.5 ns 18666667
BM_copy/homogenous_std_tuple_v1024 2251 ns 2250 ns 298667
BM_copy/homogenous_tuplet_tuple_v1024 71.6 ns 71.5 ns 8960000
BM_copy/heterogenous_std_tuple_v4 7.09 ns 7.11 ns 112000000
BM_copy/heterogenous_tuplet_tuple_v4 4.24 ns 4.24 ns 165925926
BM_copy/heterogenous_std_tuple_v8 10.6 ns 10.7 ns 64000000
BM_copy/heterogenous_tuplet_tuple_v8 6.34 ns 6.42 ns 112000000
BM_copy/heterogenous_std_tuple_v16 19.3 ns 19.0 ns 34461538
BM_copy/heterogenous_tuplet_tuple_v16 7.62 ns 6.84 ns 112000000
BM_copy/heterogenous_std_tuple_v32 36.7 ns 36.0 ns 18666667
BM_copy/heterogenous_tuplet_tuple_v32 13.6 ns 13.6 ns 89600000
BM_copy/heterogenous_std_tuple_v64 71.4 ns 71.5 ns 8960000
BM_copy/heterogenous_tuplet_tuple_v64 10.4 ns 10.3 ns 64000000
BM_copy/heterogenous_std_tuple_v128 143 ns 141 ns 4977778
BM_copy/heterogenous_tuplet_tuple_v128 14.4 ns 14.2 ns 40727273
BM_copy/heterogenous_std_tuple_v256 288 ns 285 ns 2357895
BM_copy/heterogenous_tuplet_tuple_v256 20.7 ns 20.5 ns 32000000
BM_copy/heterogenous_std_tuple_v512 562 ns 558 ns 1120000
BM_copy/heterogenous_tuplet_tuple_v512 39.1 ns 39.2 ns 17920000
BM_copy/heterogenous_std_tuple_v1024 1156 ns 1172 ns 640000
BM_copy/heterogenous_tuplet_tuple_v1024 71.0 ns 71.5 ns 8960000

gcc 11.2 (wsl)

2021-09-29T19:20:21+07:00
Running build/bench
Run on (4 X 3696 MHz CPU s)
CPU Caches:
L1 Data 32 KiB (x2)
L1 Instruction 32 KiB (x2)
L2 Unified 256 KiB (x2)
L3 Unified 3072 KiB (x1)
Load Average: 1.44, 0.36, 0.12

----------------------------------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------------------------------
BM_copy/single_elem_std_tuple_v4 5.01 ns 5.01 ns 165205659
BM_copy/single_elem_tuplet_tuple_v4 4.12 ns 4.12 ns 143344279
BM_copy/single_elem_std_tuple_v8 4.75 ns 4.75 ns 147659948
BM_copy/single_elem_tuplet_tuple_v8 4.02 ns 4.02 ns 174425182
BM_copy/single_elem_std_tuple_v16 6.55 ns 6.55 ns 106568745
BM_copy/single_elem_tuplet_tuple_v16 5.21 ns 5.21 ns 133573511
BM_copy/single_elem_std_tuple_v32 11.8 ns 11.8 ns 62642400
BM_copy/single_elem_tuplet_tuple_v32 5.53 ns 5.53 ns 134182131
BM_copy/single_elem_std_tuple_v64 16.9 ns 16.9 ns 40302847
BM_copy/single_elem_tuplet_tuple_v64 9.91 ns 9.91 ns 70095470
BM_copy/single_elem_std_tuple_v128 28.1 ns 28.1 ns 24940872
BM_copy/single_elem_tuplet_tuple_v128 16.4 ns 16.4 ns 42229526
BM_copy/single_elem_std_tuple_v256 47.6 ns 47.6 ns 14851546
BM_copy/single_elem_tuplet_tuple_v256 30.7 ns 30.7 ns 24027149
BM_copy/single_elem_std_tuple_v512 1073 ns 1073 ns 648278
BM_copy/single_elem_tuplet_tuple_v512 59.2 ns 59.2 ns 12210971
BM_copy/single_elem_std_tuple_v1024 2093 ns 2092 ns 332900
BM_copy/single_elem_tuplet_tuple_v1024 1175 ns 1175 ns 597668
BM_copy/homogenous_std_tuple_v4 4.13 ns 4.13 ns 169721451
BM_copy/homogenous_tuplet_tuple_v4 4.13 ns 4.13 ns 169640176
BM_copy/homogenous_std_tuple_v8 4.93 ns 4.93 ns 142280558
BM_copy/homogenous_tuplet_tuple_v8 4.01 ns 4.01 ns 174454872
BM_copy/homogenous_std_tuple_v16 7.09 ns 7.09 ns 98078365
BM_copy/homogenous_tuplet_tuple_v16 5.20 ns 5.20 ns 132535344
BM_copy/homogenous_std_tuple_v32 14.5 ns 14.5 ns 49674067
BM_copy/homogenous_tuplet_tuple_v32 5.22 ns 5.22 ns 132510005
BM_copy/homogenous_std_tuple_v64 23.4 ns 23.4 ns 30423407
BM_copy/homogenous_tuplet_tuple_v64 9.92 ns 9.92 ns 70227044
BM_copy/homogenous_std_tuple_v128 42.0 ns 42.0 ns 16614698
BM_copy/homogenous_tuplet_tuple_v128 16.2 ns 16.2 ns 43088564
BM_copy/homogenous_std_tuple_v256 78.7 ns 78.7 ns 8843721
BM_copy/homogenous_tuplet_tuple_v256 29.5 ns 29.5 ns 23667663
BM_copy/homogenous_std_tuple_v512 1048 ns 1048 ns 666000
BM_copy/homogenous_tuplet_tuple_v512 60.8 ns 60.8 ns 11427340
BM_copy/homogenous_std_tuple_v1024 2093 ns 2093 ns 334462
BM_copy/homogenous_tuplet_tuple_v1024 1170 ns 1170 ns 592777
BM_copy/heterogenous_std_tuple_v4 7.28 ns 7.28 ns 95980475
BM_copy/heterogenous_tuplet_tuple_v4 5.15 ns 5.15 ns 100000000
BM_copy/heterogenous_std_tuple_v8 10.7 ns 10.7 ns 65633717
BM_copy/heterogenous_tuplet_tuple_v8 4.01 ns 4.01 ns 175098843
BM_copy/heterogenous_std_tuple_v16 20.2 ns 20.2 ns 35889835
BM_copy/heterogenous_tuplet_tuple_v16 5.34 ns 5.34 ns 131968154
BM_copy/heterogenous_std_tuple_v32 36.6 ns 36.6 ns 18955498
BM_copy/heterogenous_tuplet_tuple_v32 5.22 ns 5.22 ns 130843323
BM_copy/heterogenous_std_tuple_v64 71.8 ns 71.8 ns 9742207
BM_copy/heterogenous_tuplet_tuple_v64 9.89 ns 9.89 ns 70332532
BM_copy/heterogenous_std_tuple_v128 141 ns 141 ns 4951798
BM_copy/heterogenous_tuplet_tuple_v128 16.4 ns 16.4 ns 42451823
BM_copy/heterogenous_std_tuple_v256 283 ns 283 ns 2482420
BM_copy/heterogenous_tuplet_tuple_v256 29.6 ns 29.6 ns 23765590
BM_copy/heterogenous_std_tuple_v512 1113 ns 1113 ns 628202
BM_copy/heterogenous_tuplet_tuple_v512 58.7 ns 58.7 ns 11908569
BM_copy/heterogenous_std_tuple_v1024 2234 ns 2234 ns 313064
BM_copy/heterogenous_tuplet_tuple_v1024 1170 ns 1170 ns 598089

clang-14 (wsl)
//add -fbracket-depth=10000000

2021-09-29T19:32:17+07:00
Running build/bench
Run on (4 X 3696 MHz CPU s)
CPU Caches:
L1 Data 32 KiB (x2)
L1 Instruction 32 KiB (x2)
L2 Unified 256 KiB (x2)
L3 Unified 3072 KiB (x1)
Load Average: 1.19, 0.56, 0.28

----------------------------------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------------------------------
BM_copy/single_elem_std_tuple_v4 8.45 ns 8.45 ns 81397431
BM_copy/single_elem_tuplet_tuple_v4 3.60 ns 3.60 ns 193287778
BM_copy/single_elem_std_tuple_v8 8.46 ns 8.46 ns 82478405
BM_copy/single_elem_tuplet_tuple_v8 3.60 ns 3.60 ns 196083594
BM_copy/single_elem_std_tuple_v16 8.26 ns 8.26 ns 84144021
BM_copy/single_elem_tuplet_tuple_v16 5.10 ns 5.10 ns 133441103
BM_copy/single_elem_std_tuple_v32 9.34 ns 9.34 ns 74790080
BM_copy/single_elem_tuplet_tuple_v32 5.09 ns 5.09 ns 113992776
BM_copy/single_elem_std_tuple_v64 12.4 ns 12.4 ns 56797344
BM_copy/single_elem_tuplet_tuple_v64 8.12 ns 8.12 ns 85417729
BM_copy/single_elem_std_tuple_v128 20.8 ns 20.8 ns 33616835
BM_copy/single_elem_tuplet_tuple_v128 11.9 ns 11.9 ns 58387098
BM_copy/single_elem_std_tuple_v256 41.3 ns 41.3 ns 16655500
BM_copy/single_elem_tuplet_tuple_v256 22.2 ns 22.2 ns 31655444
BM_copy/single_elem_std_tuple_v512 87.3 ns 87.3 ns 7981201
BM_copy/single_elem_tuplet_tuple_v512 41.6 ns 41.6 ns 16806884
BM_copy/single_elem_std_tuple_v1024 169 ns 169 ns 4103098
BM_copy/single_elem_tuplet_tuple_v1024 128 ns 128 ns 5476378
BM_copy/homogenous_std_tuple_v4 11.6 ns 11.6 ns 60235625
BM_copy/homogenous_tuplet_tuple_v4 4.09 ns 4.09 ns 164429872
BM_copy/homogenous_std_tuple_v8 20.3 ns 20.3 ns 34359251
BM_copy/homogenous_tuplet_tuple_v8 4.09 ns 4.09 ns 170229944
BM_copy/homogenous_std_tuple_v16 38.3 ns 38.3 ns 18405950
BM_copy/homogenous_tuplet_tuple_v16 5.46 ns 5.46 ns 127466012
BM_copy/homogenous_std_tuple_v32 77.3 ns 77.3 ns 9071823
BM_copy/homogenous_tuplet_tuple_v32 5.46 ns 5.46 ns 125107906
BM_copy/homogenous_std_tuple_v64 147 ns 147 ns 4782234
BM_copy/homogenous_tuplet_tuple_v64 8.14 ns 8.14 ns 85336402
BM_copy/homogenous_std_tuple_v128 288 ns 288 ns 2433554
BM_copy/homogenous_tuplet_tuple_v128 12.0 ns 12.0 ns 58091045
BM_copy/homogenous_std_tuple_v256 569 ns 569 ns 1229550
BM_copy/homogenous_tuplet_tuple_v256 22.5 ns 22.5 ns 31186249
BM_copy/homogenous_std_tuple_v512 1441 ns 1441 ns 485033
BM_copy/homogenous_tuplet_tuple_v512 41.9 ns 41.9 ns 16744152
BM_copy/homogenous_std_tuple_v1024 2858 ns 2858 ns 244584
BM_copy/homogenous_tuplet_tuple_v1024 128 ns 128 ns 5477261
BM_copy/heterogenous_std_tuple_v4 8.17 ns 8.17 ns 84876777
BM_copy/heterogenous_tuplet_tuple_v4 3.56 ns 3.56 ns 197448235
BM_copy/heterogenous_std_tuple_v8 12.9 ns 12.9 ns 53773312
BM_copy/heterogenous_tuplet_tuple_v8 3.55 ns 3.55 ns 196821612
BM_copy/heterogenous_std_tuple_v16 21.4 ns 21.4 ns 32678015
BM_copy/heterogenous_tuplet_tuple_v16 4.94 ns 4.94 ns 142172683
BM_copy/heterogenous_std_tuple_v32 43.5 ns 43.5 ns 16098704
BM_copy/heterogenous_tuplet_tuple_v32 4.95 ns 4.95 ns 137203249
BM_copy/heterogenous_std_tuple_v64 77.8 ns 77.8 ns 9106828
BM_copy/heterogenous_tuplet_tuple_v64 8.11 ns 8.11 ns 84803873
BM_copy/heterogenous_std_tuple_v128 151 ns 151 ns 4618825
BM_copy/heterogenous_tuplet_tuple_v128 12.1 ns 12.1 ns 58155426
BM_copy/heterogenous_std_tuple_v256 290 ns 290 ns 2415874
BM_copy/heterogenous_tuplet_tuple_v256 22.5 ns 22.5 ns 31318972
BM_copy/heterogenous_std_tuple_v512 569 ns 569 ns 1216790
BM_copy/heterogenous_tuplet_tuple_v512 41.7 ns 41.7 ns 16788443
BM_copy/heterogenous_std_tuple_v1024 1130 ns 1130 ns 616865
BM_copy/heterogenous_tuplet_tuple_v1024 128 ns 128 ns 5475492

Can't construct tuple<T, U> passing (const T&, const U&) in the constructor

I tried to use tuplet::tuple as a optional drop-in replacement for std::tuple to check if it reduces compilation times for my use case. But compilation failed. I reproduced it on godbolt.

Any ideas? Is it principal limitation of tuplet so, some wrapper function should be called or it is a bug that can be easily fixed?

#include <memory>

#ifdef USE_STD_TUPLE
#include <tuple>

using std::apply;
using std::tie;
using std::tuple;
#else
#include "https://raw.githubusercontent.com/codeinred/tuplet/main/include/tuplet/tuple.hpp"

using tuplet::apply;
using tuplet::tie;
using tuplet::tuple;
#endif

template <typename... DepValues>
class Foo {
   public:
    Foo(const std::shared_ptr<DepValues>&... deps) : m_deps(deps...) {}

   private:
    using dep_holder_t = tuple<std::shared_ptr<DepValues>...>;

    dep_holder_t m_deps;
};

int main() {
    using T = Foo<int, int>;

    T t{std::make_shared<int>(3), std::make_shared<int>(5)};
}

The concept for operator= is too loose.

I trying to use tl::expected<tuplet::tuple<...>,...>'s operator= and it failed.

The expected use SFINAE(std::is_assignable<T,U>) in operator= to determine if is unexpected error or expected value. However, the concept for tuplet::tuple is too loose so that it accept every other than type, which cause compile error.

Tightening the concept will fix it.

Clang crashes with nested tuple

Hi, thank you for this tuple implementation, I was trying to implement something similar (with little success).

I might have stumbled into a problem with Clang (tried versions 13, 14, and 15).
The issue arises when a tuple is nested into another tuple mixed with other types, like:

tuplet::tuple<int, tuplet::tuple<int>> p;

Here is a godbolt link: https://godbolt.org/z/1e1hsWv84

Since clang crashes there should be a problem on its side (which I have no idea how to solve).
I was wondering if you know any workaround to make them work together.

Thanks!

(opinion) UDL usage should be simplified

This is purely an opinion, so take with a grain of salt :)

I find the English-like numeral suffixes to be a little too "cute" and not necessarily helpful to code readability at scale. Especially when considering that, while software is often written in English, is is often written by non-native English speakers. Getting fancy with English numerals with UDL suffixes like _nd vs _rd seems like a recipe for confusion. It probably also increases the risk of unnecessary name clashes with other libraries when a particular function wants to using namespace UDLs from several different places.

I'd recommend dropping all the English-y UDLs and just sticking to _tag.

replace:

template <char... D> constexpr index_t<D...> operator""_tag() { return {}; }
template <char... D> constexpr index_t<D...> operator""_st() { return {}; }
template <char... D> constexpr index_t<D...> operator""_nd() { return {}; }
template <char... D> constexpr index_t<D...> operator""_rd() { return {}; }
template <char... D> constexpr index_t<D...> operator""_th() { return {}; }

with just:

template <char... D> constexpr index_t<D...> operator""_tag() { return {}; }

(Separately, I'm not sure the UDLs are all that helpful anyway; C++ made UDLs painful to use due to the need to always using namespace blah::literals; to access them; I'd generally just fallback to using tag<N> instead of N_tag anyway; it's one character longer, but cuts out an entire using statement.)

a better tuple_cat implementation

tuple_cat can be made far more efficient by decreasing the function instantiations and parameters passed. This has a significant effect for both compile times and for the resultant assembly generated.

A solution I came up with for my own tuplet-like library was to create a tuple of tuples, to build an index LUT for that 'big' tuple, and then to do the entire reconstruction process in a single pass.

A working version of my code is available here: https://godbolt.org/z/5WoWx8Wv6
adapted from my earlier works,
here: https://gist.github.com/mechacrash/b0b941b1bff29beb76811b69186284e6
and here: https://gist.github.com/mechacrash/39c8af5187e5f54ea6747416c1fa95c4

I reimplemented a version that works with tuplet, and supports the earliest versions of the clang, GCC and MSVC compilers that tuplet currently supports (11.X, 10.X, and 19.23 respectfully - this is limited by support for <compare>) and threw together a quick demonstration of the issue,
See a comparison here:

unoptimised
gcc : 123'700 lines of asm -> 7'860 lines of asm
clang : 116'903 lines of asm -> 8'501 lines of asm
msvc : 121'603 lines of asm -> 12'988 lines of asm

optimised (-O3, /O2)
gcc : fails to build (compilation time exceeded) -> 3 lines, fully optimised out
clang : 31'056 lines of asm -> 3 lines, fully optimised out
msvc : 63'944 lines of asm -> 4'158 lines of asm

Apologies for not supplying this as a pull request, just wanted to quickly throw this across and found this was the easiest path. You're more than welcome to use any part of this code however you like though - adapt or discard as you wish!

Visual Studio 17.1 update has broken assignment

Seems like there's a few issues with VS 17.1 and fold expressions (well, maybe that's where the issue is - not sure really) and tuplet suffers (assignment tests fail).

Whilst trying to make a minimal standalone example to post to MS, I found it was allowing invalid code: https://developercommunity.visualstudio.com/t/fold-expressions-unreliable-in-171-with-c20/1676476 (as I write, that ticket isn't live yet; stuck in some queue due to all the bugs in the new compiler being reviewed, maybe ... but hopefully will be soon).

I'm guessing once they fix that similar issue, the tuplet assignment will work again. That said, I have a workaround:

https://github.com/lukester1975/tuplet/blob/f18bc731f062524376d993810f3fd673bc02185e/include/tuplet/tuple.hpp#L294-L303

which allows assignment tests to pass again. Branch is here: https://github.com/lukester1975/tuplet/tree/cl17.1-workaround

  1. There's a few versions: simplest that I realised after the others was just to remove the identity<B2> and simply use B2. I can't see what it's there for, but might be missing something...
  2. If so, the third version void(static_cast<B1&>(*this).value = std::forward<identity_t<B2>>(u).value), ...); keeps it.
  3. Note that in this version, only the right-side of the assignment is actually required. I only changed the lhs to a cast to be consistent.
  4. There's an additional test for using tie with move as my initial "fix" (none of these versions, though) inadvertently missed a move and this new test caught it.

As an aside, could I ask the reason for the void in (void(B1::value = static_cast<U&&>(u).identity_t<B2>::value), ...); ? I've seen similar in boost. Does it avoid a warning about unused result on some compilers ... or something else?

Happy to make a PR if you want one of the workarounds.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.