qq_35875027 2017-11-22 03:50 采纳率: 0%
浏览 1193
已结题

c++construct模板的问题

template
inline void
Construct(_T1* __p, _Args&&... __args)
{ ::new(static_cast(
_p)) T1(std::forward<_Args>(_args)...); }
上面这段是我系统里的stl_construct.h里的construct模板,我用的不是SGI STL所以这段代码没用,但是这段代码是错的吧,可变参数大于2时,会用多个参数构造_T1,我查了一下SGI中的construct模板,没有查到这种可变参数版本的,想问这个模板怎么写才正确

  • 写回答

2条回答 默认 最新

  • 逆水行舟天涯路 2017-11-24 09:33
    关注

    试试这个

     template <class T1 >
    inline void
    Construct(_T1* __p, _Args&&... __args)
    {
        ::new(static_cast(_p)) T1(std::forward<_Args>(_args)...);
    }
    
    评论

报告相同问题?