wg21 | Various documents and code related to proposals for WG21

 by   BobSteagall C++ Version: v0.7.1 License: NCSA

kandi X-RAY | wg21 Summary

kandi X-RAY | wg21 Summary

wg21 is a C++ library. wg21 has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

Work on revision R7 of linear algebra proposal P1385 is currently underway in the r7 branch.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              wg21 has a low active ecosystem.
              It has 43 star(s) with 6 fork(s). There are 12 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 9 open issues and 10 have been closed. On average issues are closed in 89 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of wg21 is v0.7.1

            kandi-Quality Quality

              wg21 has 0 bugs and 0 code smells.

            kandi-Security Security

              wg21 has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              wg21 code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              wg21 is licensed under the NCSA License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              wg21 releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.
              It has 19852 lines of code, 6 functions and 7 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of wg21
            Get all kandi verified functions for this library.

            wg21 Key Features

            No Key Features are available at this moment for wg21.

            wg21 Examples and Code Snippets

            Building Manually Via CMake on Linux
            C++dot img1Lines of Code : 18dot img1License : Permissive (NCSA)
            copy iconCopy
            cd 
            mkdir build-dir
            cd build-dir
            cmake [-G ] [configuration options] ..
            cmake --build . [--config ]
            ctest [--config ]
            
            cd 
            mkdir build-debug
            cd build-debug
            cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
            cmake --build .
            ctest
            
            cd 
            mkdir build-r  
            Building Manually Via CMake on Windows 10
            C++dot img2Lines of Code : 8dot img2License : Permissive (NCSA)
            copy iconCopy
            cd 
            mkdir build-win
            cd build-win
            cmake -G "Visual Studio 16 2019" ..
            
            cmake --build . --config Debug
            ctest -C Debug
            
            cmake --build . --config Release
            ctest -C Release
              
            Installing Via CMake
            C++dot img3Lines of Code : 6dot img3License : Permissive (NCSA)
            copy iconCopy
            cd 
            mkdir build
            cd build
            
            cmake [-G ] [configuration options] -DCMAKE_INSTALL_PREFIX= ..
            cmake --build . --target install
              

            Community Discussions

            QUESTION

            Will friend injections be ill-formed?
            Asked 2022-Feb-17 at 10:23

            There used to be a paragraph in the standard which stated that

            the names of a namespace-scope friend functions of a class template specialization are not visible during an ordinary lookup unless explicitly declared at namespace scope. Such names may be found under for associated classes.

            ...

            ANSWER

            Answered 2022-Feb-17 at 10:23

            From P1787R6:

            Merged [temp.inject] into [temp.friend]

            (Adopted in N4885 in March 2021)

            The current draft (N4901) reads ([temp.friend]p2):

            Friend classes, class templates, functions, or function templates can be declared within a class template. When a template is instantiated, its friend declarations are found by name lookup as if the specialization had been explicitly declared at its point of instantiation

            Which seems to cover the old [temp.inject]p2

            Source https://stackoverflow.com/questions/71156078

            QUESTION

            std::ranges::find_if - no type in std::common_reference
            Asked 2022-Feb-16 at 16:17

            I'm using the SG14 flat_map as a container.

            As per a standard map, it takes Key and Value template parameters.

            Unlike a standard map, however, it doesn't store std::pair in a binary search tree, but rather stores the keys and values in two separate containers (additional template arguments which default to std::vector)

            ...

            ANSWER

            Answered 2022-Feb-16 at 16:17

            Why does the combination of const range and const auto& lambda argument fail to compile, while pasing a mutable range works and taking the lambda argument by value works?

            First, the operator*() of the iterator of flat_map is defined as follows:

            Source https://stackoverflow.com/questions/71143920

            QUESTION

            How to tell, whether a C++ proposal is accepted or not?
            Asked 2022-Feb-08 at 23:33

            Let's take P1907 as an example. Is it accepted into the C++ standard? To which version? When?

            ...

            ANSWER

            Answered 2022-Feb-07 at 21:51

            QUESTION

            C++ coroutine's return_void's and return_value's return type
            Asked 2022-Jan-20 at 12:51
            return_void

            consider the coroutine's ReturnObject below and note the comments before the method ReturnObject::promise_type::return_void :

            ...

            ANSWER

            Answered 2022-Jan-20 at 12:51

            QUESTION

            How to initialize std::span? Problems with const-ness
            Asked 2022-Jan-20 at 00:37

            I am trying to initialize a span — that is, a list of pointers to const data. However, the rules for const conversion amongst pointers and span<>'s available constructors are thwarting me.

            I'm sure there's a way to do it, but I cannot find the right casting/invocation.

            Aside: I'm actually not using C++20, but tcb::span, which uses the older P0122R7 set of constructors, with (pointer,size) rather than iterators. But I suspect getting something working on C++20 will get me in the right direction.

            The below example demonstrates what I'm trying to do, and some failed attempts at fixing it:

            Live link on Godbolt

            ...

            ANSWER

            Answered 2022-Jan-20 at 00:37

            QUESTION

            Why is it allowed for the C++ compiler to opmimize out memory allocations with side effects?
            Asked 2022-Jan-09 at 20:34

            Another question discusses the legitimacy for the optimizer to remove calls to new: Is the compiler allowed to optimize out heap memory allocations?. I have read the question, the answers, and N3664.

            From my understanding, the compiler is allowed to remove or merge dynamic allocations under the "as-if" rule, i.e. if the resulting program behaves as if no change was made, with respect to the abstract machine defined in the standard.

            I tested compiling the following two-files program with both clang++ and g++, and -O1 optimizations, and I don't understand how it is allowed to to remove the allocations.

            ...

            ANSWER

            Answered 2022-Jan-09 at 20:34

            Allocation elision is an optimization that is outside of and in addition to the as-if rule. Another optimization with the same properties is copy elision (not to be confused with mandatory elision, since C++17): Is it legal to elide a non-trivial copy/move constructor in initialization?.

            Source https://stackoverflow.com/questions/70645211

            QUESTION

            What is the significance of 'strongly happens before' compared to '(simply) happens before'?
            Asked 2022-Jan-02 at 18:21

            The standard defines several 'happens before' relations that extend the good old 'sequenced before' over multiple threads:

            [intro.races]

            11 An evaluation A simply happens before an evaluation B if either

            (11.1) — A is sequenced before B, or
            (11.2) — A synchronizes with B, or
            (11.3) — A simply happens before X and X simply happens before B.

            [Note 10: In the absence of consume operations, the happens before and simply happens before relations are identical. — end note]

            12 An evaluation A strongly happens before an evaluation D if, either

            (12.1) — A is sequenced before D, or
            (12.2) — A synchronizes with D, and both A and D are sequentially consistent atomic operations ([atomics.order]), or
            (12.3) — there are evaluations B and C such that A is sequenced before B, B simply happens before C, and C is sequenced before D, or
            (12.4) — there is an evaluation B such that A strongly happens before B, and B strongly happens before D.

            [Note 11: Informally, if A strongly happens before B, then A appears to be evaluated before B in all contexts. Strongly happens before excludes consume operations. — end note]

            (bold mine)

            The difference between the two seems very subtle. 'Strongly happens before' is never true for matching pairs or release-acquire operations (unless both are seq-cst), but it still respects release-acquire syncronization in a way, since operations sequenced before a release 'strongly happen before' the operations sequenced after the matching acquire.

            Why does this difference matter?

            'Strongly happens before' was introduced in C++20, and pre-C++20, 'simply happens before' used to be called 'strongly happens before'. Why was it introduced?

            [atomics.order]/4 says that the total order of all seq-cst operations is consistent with 'strongly happens before'.

            Does it mean that it's not consistent with 'simply happens before'? If so, why not?

            I'm ignoring the plain 'happens before', because it differs from 'simply happens before' only in its handling of memory_order_consume, the use of which is temporarily discouraged, since apparently most (all?) major compilers treat it as memory_order_acquire.

            I've already seen this Q&A, but it doesn't explain why 'strongly happens before' exists, and doesn't fully address what it means (it just states that it doesn't respect release-acquire syncronization, which isn't completely the case).

            Found the proposal that introduced 'simply happens before'.

            I don't fully understand it, but it explains following:

            • 'Strongly happens before' is a weakened version of 'simply happens before'.
            • The difference is only observable when seq-cst is mixed with aqc-rel on the same variable (I think, it means when an acquire load reads a value from a seq-cst store, or when an seq-cst load reads a value from a release store). But the exact effects of mixing the two are still unclear to me.
            ...

            ANSWER

            Answered 2022-Jan-02 at 18:21

            Here's my current understanding, which could be incomplete or incorrect. A verification would be appreciated.

            C++20 renamed strongly happens before to simply happens before, and introduced a new, more relaxed definition for strongly happens before, which imposes less ordering.

            Simply happens before is used to reason about the presence of data races in your code. (Actually that would be the plain 'happens before', but the two are equivalent in absence of consume operations, the use of which is discouraged by the standard, since most (all?) major compilers treat them as acquires.)

            The weaker strongly happens before is used to reason about the global order of seq-cst operations.

            This change was introduced in proposal P0668R5: Revising the C++ memory model, which is based on the paper Repairing Sequential Consistency in C/C++11 by Lahav et al (which I didn't fully read).

            The proposal explains why the change was made. Long story short, the way most compilers implement atomics on Power and ARM architectures turned out to be non-conformant in rare edge cases, and fixing the compilers had a performance cost, so they fixed the standard instead.

            The change only affects you if you mix seq-cst operations with acquire-release operations on the same atomic variable (i.e. if an acquire operation reads a value from a seq-cst store, or a seq-cst operation reads a value from a release store).

            If you don't mix operations in this manner, then you're not affected (i.e. can treat simply happens before and strongly happens before as equivalent).

            The gist of the change is that the synchronization between a seq-cst operation and the corresponding acquire/release operation no longer affects the position of this specific seq-cst operation in the global seq-cst order, but the synchronization itself is still there.

            This makes the seq-cst order for such seq-cst operations very moot, see below.

            The proposal presents following example, and I'll try to explain my understanding of it:

            Source https://stackoverflow.com/questions/70554277

            QUESTION

            Why does the C++23 ranges adaptor require a callable object to be copy_­constructible?
            Asked 2021-Dec-30 at 09:31

            Some ranges adaptors such as filter_­view, take_­while_­view and transform_view use std::optional's cousin copyable-box to store the callable object:

            ...

            ANSWER

            Answered 2021-Oct-09 at 14:20

            All the algorithms require copy-constructible function objects, and views are basically lazy algorithms.

            Historically, when these adaptors were added, views were required to be copyable, so we required the function objects to be copy_constructible (we couldn't require copyable without ruling out captureful lambdas). The change to make view only require movable came later.

            It is probably possible to relax the restriction, but it will need a paper and isn't really high priority.

            Source https://stackoverflow.com/questions/69507047

            QUESTION

            How to compute hash of std::weak_ptr?
            Asked 2021-Nov-27 at 21:43

            So I have code that uses std::weak_ptr and maintains them in an std::set, and that works just fine -- and has worked for the last 5 or 7 years. Recently I thought I'd fiddle with using them in an std::unordered_set (well, actually in an f14::F14ValueSet) and for that, I would need a hash of it. As of now, there is no std::hash, so what should I do instead?

            The answer seems to be "just hash the control block", as implied by this question and reply: Why was std::hash not defined for std::weak_ptr in C++0x?, but how do I get access to the control block? In glibc, it's located at __weak_ptr<>::_M_refcount._M_pi-> but that's private (and implementation specific). What else can I do?

            One answer is "just wait": maybe someday there will be a standard owner_hash() for std::weak_ptr, but I'd prefer something available now.

            ...

            ANSWER

            Answered 2021-Nov-27 at 21:43

            Make your own augmented weak ptr.

            It stores a hash value, and supports == based off owner_before().

            You must make these from shared_ptrs, as a weak ptr with no strong references cannot be hashed to match its owner; this could create two augmented weak ptrs that compare equal but hash differently.

            Source https://stackoverflow.com/questions/70131467

            QUESTION

            Is generating unique ID from template template parameters UB?
            Asked 2021-Nov-19 at 14:44

            I am trying to generate unique IDs from template template parameters. I tried this function

            ...

            ANSWER

            Answered 2021-Nov-19 at 14:44

            There is no UB here. The template GetID is instantiated once for each unique template argument, but GCC wrongly treats the alias templates as the template they alias itself, because they are equivalent here, as Davis Herring pointed out.

            I think the simplest general solution is to pass the argument types in the alias templates through another alias template that makes them dependent names.

            Source https://stackoverflow.com/questions/69787667

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install wg21

            You can download it from GitHub.

            Support

            P1385 is targeted for C++23. Current compiler support is as follows, but will change as new compilers become available and catch up with implementing new language features for C++20. Builds and unit testing have been successful on the following combinations of operating system and compiler:.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link