Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 65 KB, 960x720, 1445878138804.jpg [View same] [iqdb] [saucenao] [google] [report]
65231795 No.65231795 [Reply] [Original] [archived.moe] [rbt]

>C++ library
>It uses shared pointers

>> No.65232169
File: 164 KB, 413x352, 1474373650932.png [View same] [iqdb] [saucenao] [google] [report]
65232169

>only one dependency
>the dependency is boost

>> No.65232199

What is the problem with either of those?
I mean most of boost things are mostly there because you want to be able to compile it with an old compiler and shared pointers are useful in libraries.

>> No.65232201
File: 66 KB, 528x792, 1512664978810.jpg [View same] [iqdb] [saucenao] [google] [report]
65232201

>C library
>casts the return value of malloc

>> No.65232383
File: 88 KB, 750x725, 1504421848555.jpg [View same] [iqdb] [saucenao] [google] [report]
65232383

>>65232201

>> No.65233125 [DELETED] 

>>65232201
What do you plan on doing with a void*?

>> No.65233143

>>65233125
Implicit conversion

>> No.65233151

>>65233125
you don't need to explicitly cast void* in c

>> No.65233250

>>65232199
not OP, but I would think that using shared_ptr<> etc. in interfaces implies really sloppy ownership semantics in the API.

returning unique_ptr<> implies that the caller is the one true owner and that the API doesn't maintain weird ambiguous ownership in the background sometimes.

I guess you could also look at it as an idiot flag, i.e., the designer doesn't have a clear understanding of ownership at all and want to wave shared_ptr<> around like a pseudo-GC magic wand.

>> No.65234935

>>65233250
Why not return make_shared<T>(args) then?

>> No.65236055

const_cast<>(static_cast<int>(make_shared<T>(args)));

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action