mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update include/base headers for C++11/14 (see issue #3140)
See the issue for update guidelines.
This commit is contained in:
@@ -31,15 +31,11 @@
|
||||
#define CEF_INCLUDE_INTERNAL_CEF_PTR_H_
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/base/cef_ref_counted.h"
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
#include <memory> // For std::unique_ptr.
|
||||
#else
|
||||
#include "include/base/cef_scoped_ptr.h"
|
||||
#endif
|
||||
|
||||
///
|
||||
// Smart pointer implementation that is an alias of scoped_refptr from
|
||||
// include/base/cef_ref_counted.h.
|
||||
@@ -149,14 +145,8 @@
|
||||
// </pre>
|
||||
// </p>
|
||||
///
|
||||
#if defined(HAS_CPP11_TEMPLATE_ALIAS_SUPPORT)
|
||||
template <class T>
|
||||
using CefRefPtr = scoped_refptr<T>;
|
||||
#else
|
||||
// When template aliases are not supported use a define instead of subclassing
|
||||
// because it's otherwise hard to get the constructors to behave correctly.
|
||||
#define CefRefPtr scoped_refptr
|
||||
#endif
|
||||
|
||||
///
|
||||
// A CefOwnPtr<T> is like a T*, except that the destructor of CefOwnPtr<T>
|
||||
@@ -166,65 +156,13 @@ using CefRefPtr = scoped_refptr<T>;
|
||||
// thread-compatible, and once you dereference it, you get the thread safety
|
||||
// guarantees of T.
|
||||
///
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// Implementation-side code uses std::unique_ptr instead of scoped_ptr.
|
||||
template <class T, class D = std::default_delete<T>>
|
||||
using CefOwnPtr = std::unique_ptr<T, D>;
|
||||
#elif defined(HAS_CPP11_TEMPLATE_ALIAS_SUPPORT)
|
||||
template <class T, class D = base::DefaultDeleter<T>>
|
||||
using CefOwnPtr = scoped_ptr<T, D>;
|
||||
#else
|
||||
// When template aliases are not supported use a define instead of subclassing
|
||||
// because it's otherwise hard to get the constructors to behave correctly.
|
||||
#define CefOwnPtr scoped_ptr
|
||||
#endif
|
||||
|
||||
///
|
||||
// A CefRawPtr<T> is the same as T*
|
||||
///
|
||||
#if defined(HAS_CPP11_TEMPLATE_ALIAS_SUPPORT)
|
||||
#define CEF_RAW_PTR_GET(r) r
|
||||
template <class T>
|
||||
using CefRawPtr = T*;
|
||||
#else
|
||||
// Simple wrapper implementation that behaves as much like T* as possible.
|
||||
// CEF_RAW_PTR_GET is required for VS2008 compatibility (Issue #2155).
|
||||
#define CEF_RAW_PTR_GET(r) r.get()
|
||||
template <class T>
|
||||
class CefRawPtr {
|
||||
public:
|
||||
CefRawPtr() : ptr_(nullptr) {}
|
||||
CefRawPtr(T* p) : ptr_(p) {}
|
||||
CefRawPtr(const CefRawPtr& r) : ptr_(r.ptr_) {}
|
||||
|
||||
template <typename U>
|
||||
CefRawPtr(const CefRawPtr<U>& r) : ptr_(r.get()) {}
|
||||
|
||||
T* get() const { return ptr_; }
|
||||
|
||||
// Allow CefRawPtr to be used in boolean expression and comparison operations.
|
||||
operator T*() const { return ptr_; }
|
||||
|
||||
T* operator->() const {
|
||||
assert(ptr_ != NULL);
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
CefRawPtr<T>& operator=(T* p) {
|
||||
ptr_ = p;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CefRawPtr<T>& operator=(const CefRawPtr<T>& r) { return *this = r.ptr_; }
|
||||
|
||||
template <typename U>
|
||||
CefRawPtr<T>& operator=(const CefRawPtr<U>& r) {
|
||||
return *this = r.get();
|
||||
}
|
||||
|
||||
private:
|
||||
T* ptr_;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_INTERNAL_CEF_PTR_H_
|
||||
|
Reference in New Issue
Block a user