ENH: explicit convert to bool operator for autoPtr

- behaves the same as the valid() method, but can be queried directly
  like a normal raw pointer and as per std::unique_ptr.
  Eg,

      autoPtr<T> ptr = ...

      if (ptr) ...
This commit is contained in:
Mark Olesen
2018-07-30 14:33:22 +02:00
parent ff26b96a80
commit 215570915e
3 changed files with 26 additions and 1 deletions

View File

@ -143,7 +143,7 @@ int main(int argc, char *argv[])
Info<<"now have valid=" << Switch(list.valid()).c_str();
if (list.valid())
if (list)
{
Info<< nl
<< flatOutput(*list) << " @ " << long(list->cdata())
@ -153,6 +153,22 @@ int main(int argc, char *argv[])
{
Info<< nl;
}
// These should fail to compile
#if 0
label val0 = 0;
if (true)
{
val0 = list;
}
label val1 = 10;
if (val1 == list)
{
}
#endif
}
// Memory transfer