Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::optional<T>::emplace

      From cppreference.com
      <cpp‎ |experimental‎ |optional
       
       
       
       
       
      template<class...Args>
      void emplace( Args&&...args);
      (library fundamentals TS)
      template<class U,class...Args>
      void emplace(std::initializer_list<U> ilist, Args&&...args);
      (library fundamentals TS)

      Constructs the contained value in-place. If*this already contains a value before the call, the contained value is destroyed by calling its destructor.

      1) Initializes the contained value bydirect-initializing (but not direct-list-initializing) withstd::forward<Args>(args)... as parameters.
      2) Initializes the contained value by calling its constructor withilist,std::forward<Args>(args)... as parameters. This overload participates in overload resolution only ifstd::is_constructible<T,std::initializer_list<U>&, Args&&...>::value istrue.

      Contents

      [edit]Parameters

      args... - the arguments to pass to the constructor
      ilist - the initializer list to pass to the constructor
      Type requirements
      -
      T must be constructible fromArgs...
      -
      T must be constructible fromstd::initializer_list andArgs...

      [edit]Return value

      (none)

      [edit]Exceptions

      Any exception thrown by the selected constructor ofT. If an exception is thrown,*this does not contain a value after this call (the previously contained value, if any, had been destroyed).

      [edit]See also

      assigns contents
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/optional/emplace&oldid=78317"

      [8]ページ先頭

      ©2009-2025 Movatter.jp