strange syntax in stl (gnu version)

Discussion in 'C++' started by Ningyu Shi, Sep 19, 2007.

  1. Ningyu Shi

    Ningyu Shi Guest

    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?
     
    Ningyu Shi, Sep 19, 2007
    #1
    1. Advertisements

  2. Ningyu Shi

    Ian Collins Guest

    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.
     
    Ian Collins, Sep 19, 2007
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter

    1 day gnu, whole life gnu?

    Peter, Jan 10, 2005, in forum: Java
    Replies:
    3
    Views:
    497
    John C. Bollinger
    Jan 10, 2005
  2. Peter
    Replies:
    17
    Views:
    883
    Chris Smith
    Jan 13, 2005
  3. Rolf Hemmerling
    Replies:
    3
    Views:
    1,238
    tom_usenet
    Oct 10, 2003
  4. Allan Bruce

    To STL or not to STL

    Allan Bruce, Oct 16, 2003, in forum: C++
    Replies:
    41
    Views:
    1,550
    Christopher Benson-Manica
    Oct 17, 2003
  5. Markus Elfring
    Replies:
    2
    Views:
    565
    Markus Elfring
    Feb 23, 2005
  6. Harvey Twyman
    Replies:
    8
    Views:
    836
    August Derleth
    Oct 25, 2003
  7. MowGreen [MVP]
    Replies:
    5
    Views:
    2,377
    PA Bear [MS MVP]
    Feb 9, 2008
  8. Jun Kit C.

    Updata to gnu radio version 3.3

    Jun Kit C., Mar 29, 2011, in forum: Ruby
    Replies:
    0
    Views:
    172
    Jun Kit C.
    Mar 29, 2011
Loading...