<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## Variant ### 頭文件: `"boost/variant.hpp"` 通過單個頭文件就包含了所有 Variant 庫。 ``` "boost/variant/variant_fwd.hpp" ``` 包含了 `variant` 類模板的前向聲明。 ``` "boost/variant/variant.hpp" ``` 包含了 `variant` 類模板的定義。 ``` "boost/variant/apply_visitor.hpp" ``` 包含了對 `variant` 應用訪問者機制的功能。 ``` "boost/variant/get.hpp" ``` 包含了模板函數 `get`. ``` "boost/variant/bad_visit.hpp" ``` 包含了異常類 `bad_visit` 的定義。 ``` "boost/variant/static_visitor.hpp" ``` 包含了 `visitor` 類模板的定義。 以下部分摘要包含了 `variant` 類模板中最重要的成員。其它功能,如訪問者機制,類型安全的直接取回,還有更先進的特性,如通過類型列表創建類型組等等,在 "[Usage](../Text/content.html#ch07lev1sec4)" 節討論。 ``` namespace boost { template <typename T1,typename T2=unspecified, ..., typename TN=unspecified> class variant { public: variant(); variant(const variant& other); template <typename T> variant(const T& operand); template <typename U1, typename U2, ..., typename UN> variant(const variant<U1, U2, ..., UN>& operand); ~variant(); template <typename T> variant& operator=(const T& rhs); int which() const; bool empty() const; const std::type_info& type() const; bool operator==(const variant& rhs) const; bool operator<(const variant& rhs) const; }; } ``` ### 成員函數 ``` variant(); ``` 這個構造函數對 `variant` 的類型組中的第一個類型進行缺省構造。這意味著在聲明 `variant` 類型時,第一個類型必須是可以被缺省構造的,或者 `variant` 類型本身不能被缺省構造。該構造函數傳播任何從第一個類型的構造函數拋出的異常。 ``` variant(const variant& other); ``` 這個復制構造函數復制 `other` 的當前值,并傳播任何從 `other` 的當前類型的復制構造函數拋出的異常。 ``` template <typename T> variant(const T& operand); ``` 這個構造函數從 `operand` 構造一個新的 `variant` 。operand 的類型 `T`, 必須可以轉換為限定類型組中的某個類型。復制或轉換 operand 時拋出的異常將被傳播。 ``` template <typename U1,typename U2,...,typename UN> variant(const variant<U1,U2,...,UN>& operand); ``` 這個構造函數允許從另一個 `variant` 類型進行構造,后者的類型組為 `U1`, `U2`…`UN`, 它們必須可以轉換為 `T1`,`T2`…`TN` (被構造的 variant 的類型組)。復制或轉換 operand 時拋出的異常將被傳播。? ``` ~variant(); ``` 銷毀 variant, 并調用當前值的析構函數。注意,對于指針類型,不調用析構函數(銷毀指針是無操作的)。析構函數不拋出異常。 ``` template <typename T> variant& operator=(const T& rhs); ``` 這個操作符放棄當前值,并賦予值 `rhs`. 類型 `T` 必須可以轉換為 `variant` 的限定類型組中的某個類型。如果 `T` 正好是 `variant` 當前值的類型,`rhs` 被復制賦值給當前值;從 `T` 的賦值操作符拋出的異常將被傳播。如果 `variant` 當前值的類型不是 `T`, 則當前值被替換為從類型 `T` 的(復制)構造函數所創建的值。從構造函數拋出的異常將被傳播。這個函數還可能拋出 `bad_alloc`. ``` int which() const; ``` 返回一個從零起計的索引,表示當前值類型在限定類型組中的位置。這個函數不會拋出異常。 ``` bool empty() const; ``` 這個函數永遠返回 `false`, 因為一個 `variant` 永遠不會為空。這個函數的存在是為了允許泛型代碼把 `variant` 和 `boost::any` 視為同一種類型來處理。這個函數不會拋出異常。 ``` const std::type_info& type() const; ``` 返回當前值的 `type_info` 。這個函數不會拋出異常。 ``` bool operator==(const variant& rhs) const; ``` 如果 `*this` and `rhs` 相等則返回 `true` ,即 `which()==rhs.which()` 且 `*this` 的當前值與 `rhs` 根據當前值的類型的相等操作是相等的。這要求限定類型組中的所有類型都必須是可以進行等同性比較的(EqualityComparable)。當前值的類型的 `operator==` 拋出的任何異常將被傳播。 ``` bool operator<(const variant& rhs) const; ``` 小于比較返回 `which()&lt;rhs.which()` 或者,如果該索引相等,則返回對 `*this` 的當前值與 `rhs` 調用 `operator&lt;` 所返回的結果。當前值的類型的 `operator&lt;` 拋出的任何異常將被傳播。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看