Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   strange syntax in stl (gnu version) (http://www.velocityreviews.com/forums/t538372-strange-syntax-in-stl-gnu-version.html)

Ningyu Shi 09-19-2007 05:55 AM

strange syntax in stl (gnu version)
 
I saw something really wierld in g++ version of stl source.

void construct(pointer __p, const _Tp& __val) { ::new(__p)
_Tp(__val); }

anybody knows about the syntax new(__p) means? can new really take a
pointer as a parameter?


Ian Collins 09-19-2007 06:03 AM

Re: strange syntax in stl (gnu version)
 
Ningyu Shi wrote:
> I saw something really wierld in g++ version of stl source.
>
> void construct(pointer __p, const _Tp& __val) { ::new(__p)
> _Tp(__val); }
>
> anybody knows about the syntax new(__p) means? can new really take a
> pointer as a parameter?
>

Look up placement new.

--
Ian Collins.


All times are GMT. The time now is 01:41 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.