[C++ models] Fix compilation errors with make_shared/unique

Summary:
Some classes may have deleted new operator for them. To fix it, run global `new` operator instead
```
struct X {
  void* operator new(size_t) = delete;
};

X *p = new X; // compilation error
X *p = ::new X; // no compilation error
```

This change is following same strategy standard headers follow.

Reviewed By: jvillard

Differential Revision: D4500977

fbshipit-source-id: 20babfa
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent 40c84077d9
commit 87364bf8f6

@ -405,7 +405,7 @@ class enable_shared_from_this : public std__enable_shared_from_this<T> {
template <class T, class... Args>
shared_ptr<T> make_shared(Args&&... args) {
return shared_ptr<T>(new T(std::forward<Args>(args)...));
return shared_ptr<T>(::new T(std::forward<Args>(args)...));
}
#undef __cast_to_infer_ptr

@ -446,13 +446,13 @@ struct _MakeUniq2<_Tp[_Bound]> {
template <typename _Tp, typename... _Args>
inline typename _MakeUniq2<_Tp>::__single_object make_unique(
_Args&&... __args) {
return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
return unique_ptr<_Tp>(::new _Tp(std::forward<_Args>(__args)...));
}
/// std::make_unique for arrays of unknown bound
template <typename _Tp>
inline typename _MakeUniq2<_Tp>::__array make_unique(size_t __num) {
return unique_ptr<_Tp>(new typename remove_extent<_Tp>::type[__num]());
return unique_ptr<_Tp>(::new typename remove_extent<_Tp>::type[__num]());
}
/// Disable std::make_unique for arrays of known bound

Loading…
Cancel
Save