- shared_ptr array range loop doesn't work - 4 Updates
- C++ in middle english - 1 Update
"james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu>: May 23 09:39PM -0700 > return 0; > } > I've tried other combinations too, nothing works. Would this be an acceptable alternative? It compiles and executes as I expected it to: #include <iostream> #include <memory> using namespace std; struct mystruct { mystruct() { cout << "Con " << this << endl; }; ~mystruct() { cout << "Dest " << this << endl; } void func() { cout << "Func " << this << endl; } }; int main() { shared_ptr<mystruct[1][3]> sp(new mystruct[1][3]); sp[0][0].func(); sp[0][1].func(); sp[0][2].func(); for(auto &ms: sp.get()[0]) ms.func(); // <--- Doesn't compile return 0; } |
Muttley@dastardlyhq.com: May 24 08:50AM On Tue, 23 May 2023 21:39:46 -0700 (PDT) >> I've tried other combinations too, nothing works. >Would this be an acceptable alternative? It compiles and executes as I expe= >cted it to: Clang doesn't like it I'm afraid: fenris$ c++ -std=c++17 t.cc t.cc:16:32: error: no matching constructor for initialization of 'shared_ptr<mys truct[1][3]>' shared_ptr<mystruct[1][3]> sp(new mystruct[1][3]); |
Bonita Montero <Bonita.Montero@gmail.com>: May 24 02:58PM +0200 > t.cc:16:32: error: no matching constructor for initialization of 'shared_ptr<mys > truct[1][3]>' > shared_ptr<mystruct[1][3]> sp(new mystruct[1][3]); It compiled for me with clang++ 14. |
"james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu>: May 24 09:48AM -0700 > t.cc:16:32: error: no matching constructor for initialization of 'shared_ptr<mys > truct[1][3]>' > shared_ptr<mystruct[1][3]> sp(new mystruct[1][3]); On my machine, it works: clang++-14 -std=c++17 shared_pointer.cpp -o shared_pointer clang++-14 --version Ubuntu clang version 14.0.6 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin |
Muttley@dastardlyhq.com: May 24 04:25PM A bit off topic but thought this might be appreciated. I asked chatGPT to describe C++ as middle english poem. This AI is incredible: In the realme of programmynge, C++ doth resideth, A langage of myghte, its secrets it provideth. With intrikat syntax, lik a maze profounde, It chaunges the wey ofe programeers, yf yow wolde. Objects, lik knyghtes, withinne classes doth resyde, Encapsulatynge data ande methodes, they abyde. Classes, lik castels, bestowe noble myghte, Inheritance passeth lineage, shynynge bryghte. Polymorphisme, a marvelouse art to use, Transfigureth objects, takynge dyvers forme and hues. Functiones, lik minstrels, her songes they do synge, With parametres ande returnes, her melodyes sprynge. Yet, taketh heed, noble programmer, for trappes may appeere, Memory lekes ande faultes, yf yow art yclept afeared. Pointers ande referencys, thy guides in this affray, Shal guide thee to memory managynge in the righte way. So, embarketh on this journe, thou valyaunt coder, With knowledge ande skill, thine endeavor shalodour. May this Middle English spelinge, inspirynge thyne queste, Illuminate C++'s misteries ande bringe thee the beste. |
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