- OT: Github - 1 Update
- "using" declaration as a shorthand for defining constructors - 3 Updates
- copy-list-initialization - 2 Updates
- Who is God or Allah ? - 7 Updates
woodbrian77@gmail.com: May 28 06:02AM -0700 On Tuesday, May 2, 2017 at 1:52:22 PM UTC-5, Jorgen Grahn wrote: > $(CC) $(CFLAGS) -c $*.c -o $*.obj > quicklz.obj: quicklz.h > marshalling_integer.obj: marshalling_integer.hh I've changed things now to where I'm no longer building a library: https://github.com/Ebenezer-group/onwards/blob/master/makefile.windows There's one .o (.obj) that gets built, but that's it. The dependencies could be better, but a clean build takes 7 seconds on my slowest machine. Thanks for your comments. Brian Ebenezer Enterprises - "America isn't great because America is powerful. America is powerful because America is great." Ben Shapiro at dailywire.com http://webEbenezer.net |
Christiano <christiano@engineer.com>: May 28 03:08AM -0300 On 05/27/17 04:16, Alf P. Steinbach wrote: > On the other hand, as you illustrated by having a `protected` constructor in the base class, the base class distinctions of accessibility are lost, > because the `using` declaration works conceptually in the same way as a `using` declaration for a named base class function, just making it available > with the accessibility that's in effect at the point of the `using` declaration. May I disagree on this point? See this link: http://en.cppreference.com/w/cpp/language/using_declaration It says: " Using-declaration introduces a member of a base class into the derived class definition, such as to expose a protected member of base as public member of derived. " BUT the using-declaration has a different function when working with constructors. From the same link: " If the using-declaration refers to a constructor of a direct base of the class being defined (e.g. using Base::Base;), constructors of that base class are inherited, according to the following rules: [...] All candidate inherited constructors that aren't the default constructor or the copy/move constructor and whose signatures do not match user-defined constructors in the derived class, are implicitly declared in the derived class. <<====== ! I will use this at the end of the post ! [...] It has the same access as the corresponding base constructor. " That is: 1- Using-declarate works to constructors as a possibility of inheritance. This function does not matter to other methods because the other methods are naturally inherited when access is granted. It doesn't change the access. 2- Using-declarate works to others methods as a manner to expose a member of base class in derived class. Let's return to initial code: // ---------code 1---------------------- #include <iostream> using namespace std; class animal { protected: animal() { cout << "Animal constructed" << endl; } }; struct bird: animal { using animal::animal; }; int main() { bird x{}; return 0; } // ---------- end code 1 -------------- Firstly, animal has a default constructor, re-read the rule: *** [...]All candidate inherited constructors that aren't the default constructor[...] *** So, the code 1 is equivalent to: // ---------code 2---------------------- #include <iostream> using namespace std; class animal { protected: animal() { cout << "Animal constructed" << endl; } }; struct bird: animal { // nothing }; int main() { bird x{}; return 0; } // ---------- end code 2 -------------- $ CC -std=c++11 test.cpp $ ./a.out Animal constructed $ Let's do a little change on Code 1: // ---------code 3---------------------- #include <iostream> using namespace std; class animal { protected: animal(int x) { cout << "Animal constructed" << x << endl; } }; struct bird: animal { using animal::animal; }; int main() { bird x{3}; return 0; } // ---------- end code 3 -------------- As we saw, the inherited constructor "has the same access as the corresponding base constructor". So, code 3 will not work because animal constructor is *protected*. $ CC -std=c++11 test.cpp test.cpp:20:14: error: calling a protected constructor of class 'bird' bird x{3}; ^ test.cpp:15:23: note: implicitly declared protected here using animal::animal; ^ 1 error generated. $ Changing from *protected* to *public*: // ---------code 4---------------------- #include <iostream> using namespace std; class animal { public: animal(int x) { cout << "Animal constructed" << x << endl; } }; struct bird: animal { using animal::animal; }; int main() { bird x{3}; return 0; } // ---------- end code 4 -------------- $ CC -std=c++11 test.cpp $ ./a.out Animal constructed3 $ It works now because the animal constructor is public. Testing if other method has the same behavior... Lets add a function f with protected access: // ---------code 5---------------------- #include <iostream> using namespace std; class animal { public: animal(int x) { cout << "Animal constructed" << x << endl; } protected: void f(int x) // function protected added { cout << "f hello" << x << endl; } }; struct bird: animal { using animal::animal; using animal::f; // <--- Observe here }; int main() { bird x{3}; x.f(3); return 0; } // ---------- end code 5 -------------- As we saw, the code 5 will "expose a protected member of base as public member of derived." A *Different* behavior when compared to constructors. $ CC -std=c++11 test.cpp $ ./a.out Animal constructed3 f hello3 $ ____________________________________________ My conclusion: This using-declaration of the book PPP2 page 456 is wrong because it is trying "expose a protected member of base as public member of derived" through using-declaration BUT this member is a constructor that, as the cppreference says, in this situation "has the same access as the corresponding base constructor" (protected). |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: May 28 01:42PM +0200 On 28-May-17 8:08 AM, Christiano wrote: [...] > It has the same access as the corresponding base constructor. > " Oh. I didn't know. Thanks! Cheers!, - Alf |
bitrex <bitrex@de.lete.earthlink.net>: May 28 08:39AM -0400 On 05/28/2017 07:42 AM, Alf P. Steinbach wrote: > Oh. I didn't know. Thanks! > Cheers!, > - Alf So what's the "best practice" for calling constructors of wrappers/abstract class implementations where there are say multiple constructors taking parameters declared as protected in the base class? In the past in C++11 I've used perfect-forwarding constructors with variadic templates in the derived class to explicitly forward arguments to the base class constructor. But then there's this to watch out for: <https://mpark.github.io/programming/2014/06/07/beware-of-perfect-forwarding-constructors/> |
ram@zedat.fu-berlin.de (Stefan Ram): May 27 02:55PM I was not able to find the relevant part in the standard, so I wanted to try out, whether I correctly understood the meaning of copy-list-initialization. I used this program: main.cpp #include <initializer_list> #include <iostream> #include <ostream> class c { c( c & o ){ ::std::cout << "co\n"; } public: c( int const a, int const b ){ ::std::cout << "cab\n"; }}; int main(){ c x = { 1, 2 }; } transcript cab I used to believe that the right-hand side »{ 1, 2 }« was converted into a temporary object of type c and then this object was copied into c. But this should invoke the copy constructor. So, I tried to declare a private copy constructor to test my prediction that this will lead to an error message. I also tried »c( c & o)=delete;«. But there is no error message. So, the above copy-list- initialization does not use the copy constructor? (Notwithstanding optimizing away such a use during the actual execution.) |
ram@zedat.fu-berlin.de (Stefan Ram): May 28 11:02AM >I used to believe that the right-hand side »{ 1, 2 }« was >converted into a temporary object of type c and then this >object was copied into c. But this should invoke the copy Ok, the meaning of copy-list-initialization is described in 8.6.4p3.6. But since the common wisdom is that copy- initialization conceptually calls a copy constructor, I wanted some confirmation that copy-list-initialization does not in some cases. |
Mr Flibble <flibble@i42.co.uk>: May 28 01:13AM +0100 On 27/05/2017 00:16, Rick C. Hodgin wrote: > Christianity is not a religion. "Christianity[note 1] is an Abrahamic monotheistic[1] religion based on the life and teachings of Jesus Christ, who serves as the focal point for the religion. It is the world's largest religion,[2][3] with over 2.4 billion followers,[4][5][6] or 33% of the global population, known as Christians.[note 2] Christians believe that Jesus is the Son of God and the savior of humanity whose coming as the Messiah (the Christ) was prophesied in the Old Testament.[7]" https://en.wikipedia.org/wiki/Christianity /Flibble |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: May 27 05:48PM -0700 On Saturday, May 27, 2017 at 8:13:57 PM UTC-4, Mr Flibble wrote: > On 27/05/2017 00:16, Rick C. Hodgin wrote: > > Christianity is not a religion. > https://en.wikipedia.org/wiki/Christianity If you want to know the truth, see my reply to Jerry with the three YouTube videos. Jesus wants to forgive your sin without judgment, begin the process of healing, and guiding you from this day forward, because He loves you, Leigh, as His special creation of man. Thank you, Rick C. Hodgin |
Jerry Stuckle <jstucklex@attglobal.net>: May 27 09:38PM -0400 On 5/27/2017 8:48 PM, Rick C. Hodgin wrote: > because He loves you, Leigh, as His special creation of man. > Thank you, > Rick C. Hodgin But you won't answer serious questions about your religion. That and the fact you continue to pollute this and other newsgroups with off-topic posts says everything about you. Your deeds show what you are, Rick. And you will answer to God for your sins. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: May 27 07:05PM -0700 On Sat May 27, 2017, Jerry Stuckle wrote to Rick C. Hodgin: > But you won't answer serious questions about your religion. I already answered your question, but you didn't recognize my answer. Thank you, Rick C. Hodgin |
Jerry Stuckle <jstucklex@attglobal.net>: May 27 10:19PM -0400 On 5/27/2017 10:05 PM, Rick C. Hodgin wrote: > answer. > Thank you, > Rick C. Hodgin No, you didn't answer my question. You evaded it. There was nothing to recognize. So, answer my question in your own words. Is your church part of a religion, or do the leaders belong in jail for tax evasion? You can't have it both ways. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: May 27 08:07PM -0700 On Saturday, May 27, 2017 at 10:19:09 PM UTC-4, Jerry Stuckle wrote: > So, answer my question in your own words. Is your church part of a > religion, or do the leaders belong in jail for tax evasion? > You can't have it both ways. You are needlessly argumentative, Jerry, and you're looking to create controversy where none exists. 2 Tim 2:23. I have already answered you. Dig a little deeper than you're doing and you'll see it. This is my last reply to you on this matter. Thank you, Rick C. Hodgin |
Jerry Stuckle <jstucklex@attglobal.net>: May 28 07:00AM -0400 On 5/27/2017 11:07 PM, Rick C. Hodgin wrote: > this matter. > Thank you, > Rick C. Hodgin No, I'm not, Rick. I am asking valid questions which you refuse to answer. A REAL Christian can and would answer these questions. But you follow Satan, as evidenced by your actions in this and other newsgroups. You do your best to steer people AWAY from Jesus, while claiming you are a Christian. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
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