cppwp | HTML version of the current C++ working paper | Document Editor library

 by   timsong-cpp Shell Version: Current License: No License

kandi X-RAY | cppwp Summary

kandi X-RAY | cppwp Summary

cppwp is a Shell library typically used in Editor, Document Editor, Latex applications. cppwp has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

HTML version of the current C++ working paper
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              cppwp has a low active ecosystem.
              It has 320 star(s) with 15 fork(s). There are 36 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 0 open issues and 5 have been closed. On average issues are closed in 32 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of cppwp is current.

            kandi-Quality Quality

              cppwp has no bugs reported.

            kandi-Security Security

              cppwp has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              cppwp does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              cppwp releases are not available. You will need to build from source code and install.

            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 cppwp
            Get all kandi verified functions for this library.

            cppwp Key Features

            No Key Features are available at this moment for cppwp.

            cppwp Examples and Code Snippets

            No Code Snippets are available at this moment for cppwp.

            Community Discussions

            QUESTION

            What justifies the lvalue category of unevaluated non-static data members in C++?
            Asked 2021-Jun-09 at 01:53

            Both gcc and clang accept the following code, and I'm trying to figure out why.

            ...

            ANSWER

            Answered 2021-Jun-08 at 07:36

            The root of your question seems to be the difference between decltype(X::i) and decltype((X::i)). Why does (X::i) yield a int&? See:

            https://timsong-cpp.github.io/cppwp/n4861/dcl.type.decltype#1.5

            otherwise, if E is an lvalue, decltype(E) is T&, where T is the type of E;

            However, the key point here is that the fact that it yields a T& doesn't really matter:

            https://timsong-cpp.github.io/cppwp/n4861/expr.type#1

            If an expression initially has the type “reference to T” ([dcl.ref], [dcl.init.ref]), the type is adjusted to T prior to any further analysis. The expression designates the object or function denoted by the reference, and the expression is an lvalue or an xvalue, depending on the expression. [ Note: Before the lifetime of the reference has started or after it has ended, the behavior is undefined (see [basic.life]). — end note ]

            What "justifies" it then? Well, when doing decltype(X::i) we're concerned primarily with what the type of X::i is and not its value category or its properties when treated as an expression. However, (X::i) is there if we do care.

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

            QUESTION

            How does template argument deduction for f(T&()) happen?
            Asked 2021-May-30 at 02:26

            I was reading the standard, and couldn't figure out how the following code compiles.

            ...

            ANSWER

            Answered 2021-May-30 at 02:26

            This is covered in temp.deduct.type#11

            These forms can be used in the same way as T is for further composition of types.

            It might be clearer if you write your template with a different typename than T, e.g.

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

            QUESTION

            Preprocessing: Is defining a shorthand for `import` legal?
            Asked 2021-May-18 at 14:40

            For solving a code-golf challenge, I want to produce the smallest possible code. I had the idea of defining a shorthand for import:

            ...

            ANSWER

            Answered 2021-May-18 at 14:40

            No.

            [cpp.pre]/1:

            A preprocessing directive consists of a sequence of preprocessing tokens that satisfies the following constraints: At the start of translation phase 4, the first token in the sequence, referred to as a directive-introducing token, begins with the first character in the source file (optionally after whitespace containing no new-line characters) or follows whitespace containing at least one new-line character, and is [...]

            Preprocessing-directive-ness is determined at the start of translation phase 4, prior to any macro replacement. Therefore, I; is not recognized as a directive, and the import from the macro expansion of I is not replaced by the import-keyword token. This in turn means that it is not recognized as a module-import-declaration during translation phase 7, and is instead simply an ill-formed attempt to use the identifier import without a preceding declaration.

            The point of this dance is to ensure that build systems can know a file's dependencies without having to fully preprocess the file - which would be required if imports can be formed from macro replacement.

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

            QUESTION

            Does that the current draft permit to form an overload set that consists of two non-static member declarations where one has ref-qualifier
            Asked 2021-May-13 at 14:57

            The basic.scope#scope-3.3.1 says

            both declare functions with the same parameter-type-list, equivalent ([temp.over.link]) trailing requires-clauses (if any, except as specified in [temp.friend]), and, if both are non-static members, the same cv-qualifiers (if any) and ref-qualifier (if both have one)

            The above rule could be understood to, For two non-static member functions with the same parameter-type-list, if anyone has a cv-qualifiers then both declarations should have the same cv-qualifiers; if both declarations have ref-qualifier, they should have the same ref-qualifier. Otherwise, they do not correspond.

            ...

            ANSWER

            Answered 2021-May-13 at 14:57

            This change was an inadvertent result of phrasing the rules more orthogonally, but since that orthogonality allows a few additional meaningful overload sets, there hasn’t been any hurry to “fix” it. In particular, it might work well with the proposal for deducing this that’s currently under consideration.

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

            QUESTION

            Can a primitive-type data member of a derived class be used as a parameter to its base constructor?
            Asked 2021-Apr-15 at 16:49

            Inspired by my (currently deleted) answer to this question (but there's a summary in my comment thereto), I was wondering whether the constructor for the Derived class in the code below exhibits undefined behaviour.

            ...

            ANSWER

            Answered 2021-Apr-15 at 16:28

            The behavior is undefined, regardless of whether or not the Base constructor accepts the parameter by reference.

            When control reaches Base(variable = 50), the lifetime of variable hasn't started yet, because data members are initialized after base classes.

            So first, writing to it causes UB because the lifetime hasn't started yet. Then, because you pass by value, reading from it is also UB.

            [class.base.init]/13

            In a non-delegating constructor, initialization proceeds in the following order:

            — First, and only for the constructor of the most derived class ..., virtual base classes are initialized ...

            — Then, direct base classes are initialized ...

            — Then, non-static data members are initialized in the order they were declared in the class definition ...

            — Finally, the ... the constructor body is executed.

            Idea by @Jarod42: as an experiment, you can try this in a constexpr context, which is supposed to catch UB.

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

            QUESTION

            Which is the best viable operator == function between these two declarations?
            Asked 2021-Mar-24 at 15:19
            #include 
            template
            struct A{};
            struct Y{
                template
                bool operator==(A){
                    std::cout<<"#1\n";
                    return true;
                }
            };
            template
            bool operator==(T,Y){
                std::cout<<"#2\n";
                return true;
            }
            int main(){ 
                A a;
                Y y;
                a==y;
            }
            
            ...

            ANSWER

            Answered 2021-Mar-24 at 15:19

            Short answer: You used different Clang versions in your examples, Clang 11 has a correct implementation, while Clang 10 does not.

            In my answer I go into detail why Clang 11 and MSVC are right and GCC is wrong in both cases.

            From [over.match.oper]#3 the candidates include four sets:

            For [...] a binary operator @ [...] four sets of candidate functions, designated member candidates, non-member candidates, built-in candidates, and rewritten candidates, are constructed as follows:

            In your case the rewritten candidates are determined by [over.match.oper]#3.4.4:

            For the equality operators, the rewritten candidates also include a synthesized candidate, with the order of the two parameters reversed, for each non-rewritten candidate for the expression y == x.

            In your case for an expression x == y the candidates of interest are:

            • member candidates: candidates for x.operator==(y)
            • non-member candidates: candidates for operator==(x, y)
            • rewritten candidates: non-rewritten candidates for y == x, which are y.operator==(x) and operator==(y, x).

            Let's look at your two examples and determine the best candidate.

            First example

            For the expression a == y the candidates are:

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

            QUESTION

            Does the current standard guarantee to invoke the destructor for subobject when the initialization of the complete object throws an exception
            Asked 2021-Mar-18 at 02:24

            In section except.ctor, the rule states:

            1. As control passes from the point where an exception is thrown to a handler, objects with automatic storage duration are destroyed by a process, specified in this subclause, called stack unwinding.
            2. [...]
            3. If the initialization or destruction of an object other than by delegating constructor is terminated by an exception, the destructor is invoked for each of the object's direct subobjects and, for a complete object, virtual base class subobjects, whose initialization has completed ([dcl.init]) and whose destructor has not yet begun execution, except that in the case of destruction, the variant members of a union-like class are not destroyed. [ Note: If such an object has a reference member that extends the lifetime of a temporary object, this ends the lifetime of the reference member, so the lifetime of the temporary object is effectively not extended. — end note ] The subobjects are destroyed in the reverse order of the completion of their construction. Such destruction is sequenced before entering a handler of the function-try-block of the constructor or destructor, if any.

            According to bullet 3, which states can be also considered as a part of the process of stack unwinding. Since the first rule sounds like that the invocation of stack unwinding is only for the object with automatic storage duration. Doesn't that stack unwinding invoke for the object with dynamic storage duration or others duration?

            ...

            ANSWER

            Answered 2021-Mar-18 at 02:24

            By the plain wording of [except.ctor]/3, it applies to objects with any storage duration, as long as they are subobjects of an object whose construction was terminated by an exception. This should not be controversial.

            However, the wording of [except.ctor] has changed over time, and this seems to have created some issues which the OP has noticed. The background is that the wording used to be simliar to the current wording, with "stack unwinding" only referring to the destruction of automatic objects, and someone noticed that this created an inconsistency, where, when no matching handler is found, it is not guaranteed whether stack unwinding occurs, but it is guaranteed that subobject destruction occurs (since there is nothing in the text to say that it may not happen if a handler is not found). This was CWG 1774. CWG agreed that this inconsistency was undesirable (and perhaps it was unintentional, though that page doesn't say). So the wording was changed so that subobject destruction would be an aspect of "stack unwinding", and thus covered under [except.handle]/9, instead of being a separate process. But then later, to resolve a different DR that has nothing to do with exceptions, the old wording was added back, and I'm 90% sure that it was unintentional. The intent of the resolution to CWG2256 was just to avoid discrimination against trivially destructible objects, and not to actually change anything about exception handling.

            Therefore, the current wording is defective, and the standard should still be read as if "stack unwinding" includes subobject destruction (i.e., the resolution to CWG 1774 stands). You might even be able to fix this editorially (i.e., submit a pull request against the standard source).

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

            QUESTION

            Undefined behavior of constexpr static cast from int to scoped enum with non-fixed underlying type compiles in C++17
            Asked 2021-Mar-16 at 23:45

            I wonder if the following should or should not compile in C++17

            ...

            ANSWER

            Answered 2021-Mar-16 at 23:45

            Scoped enums always have fixed underlying type. [dcl.enum]/5 (C++17):

            For a scoped enumeration type, the underlying type is int if it is not explicitly specified. In both of these cases, the underlying type is said to be fixed.

            So your E has fixed underlying type of int. Then in paragraph 8:

            For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type.

            2 is in range for int, so by the text you quoted from [expr.static.cast], the behaviour of the cast is well-defined.

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

            QUESTION

            How to understand the partial ordering by constraints
            Asked 2021-Mar-11 at 12:47

            The partial ordering rules of constraints are defined as:
            [temp.constr.order#1]

            A constraint P subsumes a constraint Q if and only if, for every disjunctive clause Pi in the disjunctive normal form of P, Pi subsumes every conjunctive clause Qj in the conjunctive normal form of Q, where

            • a disjunctive clause Pi subsumes a conjunctive clause Qj if and only if there exists an atomic constraint Pia in Pi for which there exists an atomic constraint Qjb in Qj such that Pia subsumes Qjb, and
            • an atomic constraint A subsumes another atomic constraint B if and only if A and B are identical using the rules described in [temp.constr.atomic].

            I don't know how to get the disjunctive and conjunctive normal forms of a given constraint. Moreover, I have some confusion about the second bullet.

            Question 1:

            Given a constraint named P with the form A ∧ B and another constraint named Q with the form A where A and B are both atomic constraints. For constraint P what's the disjunctive normal form of it? Whereas, what's the conjunctive and disjunctive normal form of Q?

            Question 2:

            Is that Pi and Qj is taken from the clauses of the corresponding positions of their disjunctive /conjunctive normal form? Especially, how to understand the sentence if and only if there exists an atomic constraint Pia in Pi for which there exists an atomic constraint Qjb in Qj such that Pia subsumes Qjb? How to interpret the case that Qi has an extra atomic constraint that Pi does not have? Does that P subsumes Q? Could you give an exposition process to interpret why does A ∧ B subsume A?

            ...

            ANSWER

            Answered 2021-Mar-11 at 12:47

            Both A ∧ B and A are already in disjunctive normal form and conjunctive normal form.

            In this case, there is one disjunctive clause in P, and one conjunctive clause in Q.

            You then check if any subclause of P0 (A ∧ B) subsumes any subclause of Q0 (A), which it does (A subsumes A).

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

            QUESTION

            Member access rules for friend of derived class, where the naming class is the base class
            Asked 2021-Mar-11 at 05:49

            All standard references below refer, unless noted otherwise, to N4861 (March 2020 post-Prague working draft/C++20 DIS).

            Background

            According to [class.access.base]/5:

            If a base class is accessible, one can implicitly convert a pointer to a derived class to a pointer to that base class [...].

            Meaning the following example is well-formed:

            ...

            ANSWER

            Answered 2021-Mar-11 at 05:49

            Actually, the section [class.protected#1] is an additional clause for [class.access.base#5] when the nominated member is a protected member of the naming class to which R occurs at a member or friend of a derived class.
            According to class.access.base#1, the non-static protected member of N is accessible as a private member of the derived class P. We are permitted to access the member m in a friend of P as per class.access.base#5.2, if the naming class is P

            m as a member of N is private, and R occurs in a member or friend of class N, or

            Back to [class.protected#1], we should take a look at the following rule:

            An additional access check beyond those described earlier in Clause [class.access] is applied when a non-static data member or non-static member function is a protected member of its naming class ([class.access.base])115 As described earlier, access to a protected member is granted because the reference occurs in a friend or member of some class C.

            In other words, the rule says that only if these conditions are satisfied will the additional rule be applied. That is:

            1. The member should first be a non-static member(data or function)
            2. The member should be a protected member of the naming class.

            In order to make the additional rule apply, the following conditions should also be satisfied

            1. As described earlier, access to a protected member is granted because the reference occurs in a friend or member of some class C.
            2. If the access is to form a pointer to member ([expr.unary.op]), the nested-name-specifier shall denote C or a class derived from C.
            3. All other accesses involve a (possibly implicit) object expression. In this case, the class of the object expression shall be C or a class derived from C.

            Condition 3 might have some confusion, however, it does not say C must be the naming class or not. It just says that the member can be accessible in a member or friend of C.

            After sorting out these conditions, we could take a look at the example

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

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

            Vulnerabilities

            No vulnerabilities reported

            Install cppwp

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

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

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/timsong-cpp/cppwp.git

          • CLI

            gh repo clone timsong-cpp/cppwp

          • sshUrl

            git@github.com:timsong-cpp/cppwp.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link