<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Jul 8, 2013, at 4:05 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Mon, Jul 8, 2013 at 2:51 PM, Argyrios Kyrtzidis <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>> wrote:<br><blockquote type="cite">On Jul 8, 2013, at 12:47 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br><br>On Mon, Jul 8, 2013 at 12:12 PM, Argyrios Kyrtzidis <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>><br>wrote:<br><br>Author: akirtzidis<br>Date: Mon Jul  8 14:12:01 2013<br>New Revision: 185851<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=185851&view=rev">http://llvm.org/viewvc/llvm-project?rev=185851&view=rev</a><br>Log:<br>[ADT/NullablePtr] Allow implicit conversion of NullablePtr<OtherT> -><br>NullablePtr<T> if OtherT is derived from T.<br><br><br>Might be nicer to do this for any case where SrcT* is implicitly<br>convertible DestT* (such as adding cv qualifiers or converting to<br>void*).<br><br><br>cv qualifiers look like are working, void* is not.<br>In general, we need to add the equivalent of C++11's is_convertible to<br>"llvm/Support/type_traits.h" and use it here.<br></blockquote><br>Shall we do that then?<br><br>(your current implementation also disables this ctor for NullablePtr's<br>of non-class type (NullablePtr<int> for example), I think... that<br>seems unreasonable)<br></div></blockquote><div dir="auto"><br></div><div dir="auto">Feel free to enhance it :-)</div><div dir="auto"><br></div><div dir="auto">-Argyrios</div><br><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br><blockquote type="cite"><br><br><br>Modified:<br>  llvm/trunk/include/llvm/ADT/NullablePtr.h<br><br>Modified: llvm/trunk/include/llvm/ADT/NullablePtr.h<br>URL:<br><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/NullablePtr.h?rev=185851&r1=185850&r2=185851&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/NullablePtr.h?rev=185851&r1=185850&r2=185851&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/ADT/NullablePtr.h (original)<br>+++ llvm/trunk/include/llvm/ADT/NullablePtr.h Mon Jul  8 14:12:01 2013<br>@@ -14,6 +14,7 @@<br>#ifndef LLVM_ADT_NULLABLEPTR_H<br>#define LLVM_ADT_NULLABLEPTR_H<br><br>+#include "llvm/Support/type_traits.h"<br>#include <cassert><br>#include <cstddef><br><br>@@ -25,8 +26,17 @@ namespace llvm {<br>template<class T><br>class NullablePtr {<br> T *Ptr;<br>+  struct PlaceHolder {};<br>+<br>public:<br> NullablePtr(T *P = 0) : Ptr(P) {}<br>+<br>+  template<typename OtherT><br>+  NullablePtr(NullablePtr<OtherT> Other,<br>+              typename enable_if<<br>+                is_base_of<T, OtherT>,<br>+                PlaceHolder<br>+              >::type = PlaceHolder()) : Ptr(Other.getPtrOrNull()) {}<br><br> bool isNull() const { return Ptr == 0; }<br> bool isNonNull() const { return Ptr != 0; }<br><br><br>_______________________________________________<br>llvm-commits mailing list<br>llvm-commits@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</blockquote></div></blockquote></div><br></body></html>