Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Portable way to use shared_ptr in GCC

GCC 4.1 uses the <tr1/memory> header and GCC 4.3 uses <memory> header, I need a portable way to use shared_ptr with GCC 4.3.2 and with GCC 4.2.1, is there any way to do that without checking GCC version macros or using external libraries like Boost ?

like image 748
Tarantula Avatar asked Feb 26 '23 17:02

Tarantula


2 Answers

<tr1/memory> will still work with gcc 4.3. If you wan to support both versions, just use the tr1 name.

like image 108
R Samuel Klatchko Avatar answered Mar 05 '23 16:03

R Samuel Klatchko


Haven't tried this solution, but you might be able to add tr1 to the list of include directories on the gcc command line (-I or -isystem)

like image 45
joesdiner Avatar answered Mar 05 '23 18:03

joesdiner