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

Added SharedPointer constructors with initializer lists.

parent 8551431a
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -90,6 +90,34 @@ class SharedPointer< 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  SharedPointer( 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  SharedPointer( std::initializer_list< std::initializer_list< Value > > list )
      : pd( nullptr ),
        cuda_pointer( nullptr )
      {
         this->allocate( list );
      }

      /**
       * \brief Copy constructor.
       *
+33 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer
       * \brief Constructor with parameters of the Object constructor.
       *
       * \tparam Args is variadic template type of arguments of the Object constructor.
       * \tparam args are arguments passed to the Object constructor.
       * \param args are arguments passed to the Object constructor.
       */
      template< typename... Args >
      explicit  SharedPointer( Args... args )
@@ -85,6 +85,38 @@ class SharedPointer< Object, Devices::Host > : 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  SharedPointer( std::initializer_list< Value > list )
      : pd( nullptr )
      {
#ifdef TNL_DEBUG_SHARED_POINTERS
         std::cerr << "Creating shared pointer to " << getType< ObjectType >() << std::endl;
#endif
         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  SharedPointer( std::initializer_list< std::initializer_list< Value > > list )
      : pd( nullptr )
      {
#ifdef TNL_DEBUG_SHARED_POINTERS
         std::cerr << "Creating shared pointer to " << getType< ObjectType >() << std::endl;
#endif
         this->allocate( list );
      }

      /**
       * \brief Copy constructor.
       *