C++11

当前头文件是通用工具库(Diagnostics library)中的部分内容。

​通用工具库(参考手册) ​通用工具库(标准)

  • tuple 实现了多元组,这是一个编译期就确定大小(Implements fixed)的容器,可以容纳不同类型的元素
    tuple_size 在编译期获得 tuple 的大小
    tuple_element 获得指定元素的类型
    std::uses_allocator<std::tuple> C++11 std::tuple 特例化 std::uses_allocator 类型特征(Type trait)
  • ignore 当使用 tie 拆分一个 tuple 对象时,用以跳过一个元素的占位符(Placeholder)
  • make_tuple 创建由参数的类型定义的多元组(Tuple)对象
    tie 创建由左值引用(Lvalue reference)组成的多元组或拆分一个多元组为多个单独对象
    forward_as_tuple 创建由右值引用(Rvalue reference)组成的多元组
    tuple_cat 通过连接(Concatenate)任意数目的多元组来创建多元组
    std::get(std::tuple) 访问指定元素
    operator==
    operator!=
    operator<
    operator<=
    operator>
    operator>=
    对 tuple 对象中的值按字典序(Lexicographically)进行比较 
    std::swap(std::tuple) std::swap 函数对 std::tuple 的特例化
  • namespace std {
     
        // class template tuple:
        template <class... Types> class tuple;
     
        // tuple creation functions:
        const /*unspecified*/ ignore;
        template <class... Types>
            tuple<VTypes...> make_tuple(Types&&...);
        template <class... Types>
            tuple<Types...> forward_as_tuple(Types&&...) noexcept;
        template<class... Types>
            tuple<Types&...> tie(Types&...) noexcept;
        template <class... Tuples>
            tuple<Ctypes...> tuple_cat(Tuples&&...);
     
        //  tuple helper classes:
        template <class T> class tuple_size; // undefined
        template <class T> class tuple_size<const T>;
        template <class T> class tuple_size<volatile T>;
        template <class T> class tuple_size<const volatile T>;
        template <class... Types> class tuple_size<tuple<Types...> >;
     
        template    <size_t I,  class   T>  class   tuple_element; // undefined
        template    <size_t I,  class   T>  class   tuple_element<I, const T>;
        template    <size_t I,  class   T>  class   tuple_element<I, volatile T>;
        template    <size_t I,  class   T>  class   tuple_element<I, const volatile T>;
        template <size_t I, class... Types> class tuple_element<I, tuple<Types...> >;
     
        //  element access:
        template <size_t I, class... Types>
            typename tuple_element<I, tuple<Types...> >::type& get(tuple<Types...>&) noexcept;
        template <size_t I, class... types>
            typename tuple_element<I, tuple<Types...> >::type&& get(tuple<Types...>&&) noexcept;
        template <size_t I, class... types>
            typename tuple_element<I, tuple<Types...> >::type const& get(const tuple<Types...>&) noexcept;
     
        //relational operators:
        template<class... TTypes, class... UTypes>
            bool operator==(const tuple<TTypes...>&, const tuple<UTypes...>&);
        template<class... TTypes, class... UTypes>
            bool operator<(const tuple<TTypes...>&, const tuple<UTypes...>&);
        template<class... TTypes, class... UTypes>
            bool operator!=(const tuple<TTypes...>&, const tuple<UTypes...>&);
        template<class... TTypes, class... UTypes>
            bool operator>(const tuple<TTypes...>&, const tuple<UTypes...>&);
        template<class... TTypes, class... UTypes>
            bool operator<=(const tuple<TTypes...>&, const tuple<UTypes...>&);
        template<class... TTypes, class... UTypes>
            bool operator>=(const tuple<TTypes...>&, const tuple<UTypes...>&);
     
        // allocator-related traits
        template <class... Types, class Alloc>
            struct uses_allocator<tuple<Types...>, Alloc>;
        // specialized algorithms:
        template <class... Types>
            void swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(x.swap(y));
    }
  • template <class... Types>
    class tuple {
    public:
        // tuple construction
        constexpr tuple();
        explicit tuple(const Types&...);
        template <class... UTypes>
            explicit tuple(UTypes&&...);
        tuple(const tuple&) = default;
        tuple(tuple&&) = default;
        template <class... UTypes>
            tuple(const tuple<UTypes...>&); 
        template <class... UTypes>
            tuple(tuple<UTypes...>&&);
        template <class U1, class U2>
            tuple(const pair<U1, U2>&);  // iff sizeof...(Types) == 2
        template <class U1, class U2>
            tuple(pair<U1, U2>&&);       // iff sizeof...(Types) == 2
     
        // allocator-extended constructors
        template <class Alloc>
            tuple(allocator_arg_t, const Alloc& a);
        template <class Alloc>
            tuple(allocator_arg_t, const Alloc& a, const Types&...);
        template <class Alloc, class... UTypes>
            tuple(allocator_arg_t, const Alloc& a, const UTypes&&...);
        template <class Alloc>
            tuple(allocator_arg_t, const Alloc& a, const tuple&);
        template <class Alloc>
            tuple(allocator_arg_t, const Alloc& a, tuple&&);
        template <class Alloc, class... UTypes>
            tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
        template <class Alloc, class... UTypes>
            tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
        template <class Alloc, class U1, class U2>
            tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
        template <class Alloc, class U1, class U2>
            tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
     
        // tuple assignment
        tuple& operator=(const tuple&);
        tuple& operator=(tuple&&) noexcept(see below);
        template <class... UTypes>
            tuple& operator=(const tuple<UTypes...>&);
        template <class... UTypes>
            tuple& operator=(tuple<UTypes...>&&);
        template <class U1, class U2>
            tuple& operator=(const pair<U1, U2>&); // iff sizeof...(Types) == 2
        template <class U1, class U2>
            tuple& operator=(pair<U1, U2>&&) noexcept; // iff sizeof...(Types) == 2
     
        // tuple swap
        void swap(tuple&) noexcept(see below);
    };