Commit d7d8c808 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Add initializer list constructors to UniquePointer.

parent 0a511aac
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -96,6 +96,30 @@ class UniquePointer< Object, Devices::Host > : public SmartPointer
         this->pointer = new Object( args... );
      }

      /**
       * \brief Constructor with initializer list.
       *
       * \tparam Value is type of the initializer list elements.
       * \param list is the instance of the initializer list..
       */
      template< typename Value >
      explicit  UniquePointer( std::initializer_list< Value > list )
      {
         this->pointer = new Object( list );
      }

      /**
       * \brief Constructor with nested initializer lists.
       *
       * \tparam Value is type of the nested initializer list elements.
       * \param list is the instance of the nested initializer list..
       */
      template< typename Value >
      explicit  UniquePointer( std::initializer_list< std::initializer_list< Value > > list )
      {
         this->pointer = new Object( list );
      }

      /**
       * \brief Arrow operator for accessing the object owned by constant smart pointer.
       *
@@ -300,6 +324,34 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer
         this->allocate( args... );
      }

      /**
       * \brief Constructor with initializer list.
       *
       * \tparam Value is type of the initializer list elements.
       * \param list is the instance of the initializer list..
       */
      template< typename Value >
      explicit  UniquePointer( std::initializer_list< Value > list )
      : pd( nullptr ),
        cuda_pointer( nullptr )
      {
         this->allocate( list );
      }

      /**
       * \brief Constructor with nested initializer lists.
       *
       * \tparam Value is type of the nested initializer list elements.
       * \param list is the instance of the nested initializer list..
       */
      template< typename Value >
      explicit  UniquePointer( std::initializer_list< std::initializer_list< Value > > list )
      : pd( nullptr ),
        cuda_pointer( nullptr )
      {
         this->allocate( list );
      }

      /**
       * \brief Arrow operator for accessing the object owned by constant smart pointer.
       *