Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Commit

Permalink
Enable directly calling the underlying constructor for ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
Till Varoquaux committed Nov 12, 2013
1 parent 5b478d6 commit 08847ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions async/refcnt.C
Expand Up @@ -46,6 +46,7 @@ bool __globaldestruction_t::started;

#include "callback.h"

const ptr_alloc_t ptr_alloc = {};

static void
ignore_void ()
Expand Down
12 changes: 12 additions & 0 deletions async/refcnt.h
Expand Up @@ -477,6 +477,13 @@ class ref : public refpriv, public refops<T> {
/* To skip initialization of ptr's in BSS */
struct __bss_init {};

// Dummy argument to force the ptr to call the constructor for the underlying
// class
class ptr_alloc_t {};

extern const ptr_alloc_t ptr_alloc;


template<class T>
class ptr : public refpriv, public refops <T> {
friend class refpriv;
Expand Down Expand Up @@ -529,6 +536,11 @@ class ptr : public refpriv, public refops <T> {
ptr (::ref<U>&& src) : ptr<T>(src) { }
#endif

template <typename... Params>
ptr(const ptr_alloc_t&, Params&&... args) :
ptr(New refcounted<T>(std::forward<Params>(args)...))
{}

~ptr () { dec (); }

ptr<T> &operator= (privtype *)
Expand Down

0 comments on commit 08847ac

Please sign in to comment.