- C++ needs some help - 1 Update
- Constructors again - 4 Updates
- Use of decltype - 2 Updates
- "delete" - 4 Updates
- Constructors again - 2 Updates
woodbrian77@gmail.com: Mar 14 03:46PM -0700 On Sunday, February 14, 2016 at 5:16:49 PM UTC-6, Mr Flibble wrote: > Wikipedia is an encyclopaedia not a website for posting a free > advertisement for a product by its author. Pack it in mate. > If you add it again I will remove it again. I wonder if you recall me posting how "The Stone which the builders rejected has become The Chief Cornerstone"? https://www.biblegateway.com/passage/?search=Psalms+118&version=NASB I'm sorry, but I don't think the other libraries mentioned for C++ serialization options will endure like the the C++ Middleware Writer. Brian Ebenezer Enterprises - "The L-rd will make you the head and not the tail, and you only will be above, and you will not be underneath, if you listen to the commandments of the L-rd your G-d, which I charge you today, to observe them carefully, and do not turn aside from any of the words which I command you today, to the right or to the left, to go after other gods to serve them." Deuteronomy 28:13,14 http://webEbenezer.net |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Mar 14 01:09AM On 14 Mar 2016 00:49:09 GMT > (Clause 9) with either no default constructor (12.1) or > a default constructor that is user-provided or deleted, > then the object is default-initialized;« This is not in §8.1 of any C++ standard I have looked at. What version are you quoting? You also seem to have incorrectly pasted the text because if the default constructor is deleted then I cannot see how an object could be default initialized at all. You may need to repost the text in question. [snip] Chris |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 14 09:39AM +0100 On 14.03.2016 02:09, Chris Vine wrote: >> then the object is default-initialized;« > This is not in §8.1 of any C++ standard I have looked at. What version > are you quoting? It's C++14 or later. N3936 was the last working draft before C++14. The wording was introduced in the resolution of [1]defect report 1301 "Value initialization of union" – it's the definition of value initialization. Recall that Andrew Koenig proposed value initialization for C++03, in order to get rid of quite counter-intuitive behavior for default initialization (or not) of aggregates in C++98. It was the only new thing in C++03, which otherwise was just a collection of bug fixes, the Technical Corrigendum 1, TC1. And to some degree also value initialization might be considered a bug fix. So this all started out as at least partially a bug fix, but the fix was weird enough to yield unanticipated undesirable effects with the rules of C++11, which caused additional bug fixes in C++14. And MAYBE the wording makes some kind of technical sense. But in my humble opinion they just fucked up, because that wording does not make sense to an ordinary reader, even one well versed in C++ standardese. > You also seem to have incorrectly pasted the text > because if the default constructor is deleted then I cannot see how an > object could be default initialized at all. The text is correctly pasted. And apparently it's got something to do with value initialization of a union. But I agree, it's really nonsense, they bungled it. There's also other nonsense in C++14, e.g. support for premature micro-optimizations of allocations, where a sequence of small allocations can be changed into a single one. Just a complication of things, addressing internal implementation details. It reads like a first year student of not particularly high ability has got access to define the C++ standard. I think the committee must have ceased working as a real standards body as of C++14. > You may need to repost the text in question. C++14 (as of the N3936 draft) §8.5/8 To value-initialize an object of type T means: — if T is a (possibly cv-qualified) class type (Clause 9) with either no default constructor (12.1) or a default constructor that is user-provided or deleted, then the object is default-initialized; — if T is a (possibly cv-qualified) class type without a user-provided or deleted default constructor, then the object is zero-initialized and the semantic constraints for default-initialization are checked, and if T has a non-trivial default constructor, the object is default-initialized; — if T is an array type, then each element is value-initialized; — otherwise, the object is zero-initialized. Cheers & hth., - Alf Notes: [1] <url: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1301> |
woodbrian77@gmail.com: Mar 14 02:01PM -0700 On Monday, March 14, 2016 at 3:39:41 AM UTC-5, Alf P. Steinbach wrote: Alf, please don't swear here. Brian |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 14 10:30PM +0100 > On Monday, March 14, 2016 at 3:39:41 AM UTC-5, Alf P. Steinbach wrote: > Alf, please don't swear here. Oh. Sorry. That was just a little SNAFU ;-) Cheers, & hope didn't ruin your day, - Alf |
Juha Nieminen <nospam@thanks.invalid>: Mar 14 09:16AM > typedef is fine too, but I have trouble remembering whether it should be > typedef int PseudonymForInt; or typedef PseudonymForInt int; (The first > is correct, I think. It's rather easy. It uses the exact same principle as declaring a variable. For example, if you want a variable named "foo" of type int, you write: int foo; To make it a type alias, simply add 'typedef' at the beginning: typedef int foo; This same idea works with more complex types as well. For example, if you are declaring an array of 3 ints named 'foo', it would be: int foo[3]; Add 'typedef' at the beginning, and it becomes a type alias for such a thing: typedef int foo[3]; If you are declaring, let's say, a function pointer to int(double) named "foo", it would be: int(*foo)(double); Now add 'typedef' at the beginning and it becomes a type alias: typedef int(*foo)(double); (Now 'foo' is a type alias for a function pointer to a function of type int(double).) --- news://freenews.netfront.net/ - complaints: news@netfront.net --- |
woodbrian77@gmail.com: Mar 14 11:20AM -0700 On Monday, March 14, 2016 at 4:16:54 AM UTC-5, Juha Nieminen wrote: > typedef int(*foo)(double); > (Now 'foo' is a type alias for a function pointer to a function of type > int(double).) I think the using approach is clearer than the typedef approach. And from a code generator perspective the using approach is easier to support. Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
Victor Bazarov <v.bazarov@comcast.invalid>: Mar 14 10:38AM -0400 On 3/14/2016 9:37 AM, Stefan Ram wrote: > int main() > { f( 2.3 ); > /* f( 2 ); */ } Don't you think a bit more information would help understanding your assertion? Which "part of the specification of C++" did you read? What in it suggested to you the validity of your code? Once you "made this up", what was the reaction of your compiler when you fed it your code? V -- I do not respond to top-posted replies, please don't ask |
Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid>: Mar 14 04:39PM +0100 > I read a part of the specification of C++. It suggests than > one can use »delete« outside of a class! I never saw this > before, but I made this up: It lets you forbid the use of a particular template instanciation. template <typename T> void f(T x) {...} // Call f on everything void f(int) = delete; // except ints Or disallows implicit (silent) type casts: void f(double x) { ... } void f(int) = delete; -- Alain. |
Victor Bazarov <v.bazarov@comcast.invalid>: Mar 14 11:58AM -0400 On 3/14/2016 11:39 AM, Alain Ketterlin wrote: > It lets you forbid the use of a particular template instanciation. > template <typename T> void f(T x) {...} // Call f on everything > void f(int) = delete; // except ints Shouldn't this "definition" be a template declaration, though? I.e. template<> void f(int) = delete; ? > void f(double x) { ... } > void f(int) = delete; > -- Alain. V -- I do not respond to top-posted replies, please don't ask |
Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid>: Mar 14 05:12PM +0100 >> void f(int) = delete; // except ints > Shouldn't this "definition" be a template declaration, though? I.e. > template<> void f(int) = delete; Yes, you're right. I finally tested this and my compiler didn't complain, in either case (unless I call f(1), of course). I even tried putting both (without complaint). When calling f(1) the compiler selected the non-template version to tell me I wasn't allowed to call f(int). I don't know the exact rule (or forgot it). Anyway, thanks for the correction. -- Alain. |
ram@zedat.fu-berlin.de (Stefan Ram): Mar 14 12:49AM I might have asked a similar question already. But maybe there was no answer or maybe I still do not understand it. A specification for C++ says: »(8.1) --- if T is a (possibly cv-qualified) class type (Clause 9) with either no default constructor (12.1) or a default constructor that is user-provided or deleted, then the object is default-initialized;« So, there seem to be the following possibilities when T is a class type, and they all seem to be different: A it has no default constructor B it has a default constructor that is user-provided C it has a default constructor that is deleted D (implied) it has a default constructor that is neither user-provided nor deleted I am not sure whether I can understand the difference between no default constructor (A) and a deleted default constructor (C). When a class has a deleted default constructor (C), doesn't this imply that it has no default constructor (A)? Could somone kindly write an example class definition for each of these distinct four cases A, B, C, and D? |
ram@zedat.fu-berlin.de (Stefan Ram): Mar 14 01:37PM I read a part of the specification of C++. It suggests than one can use »delete« outside of a class! I never saw this before, but I made this up: void f( double ){} void f( int )= delete; int main() { f( 2.3 ); /* f( 2 ); */ } |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment