"Statement: All rights reserved, reproduced please indicate the source, do not use for commercial purposes." Contact Email: libin493073668@sina.com "
17.1 Tuple Type
1.tuple is a template similar to pair. Each pair has a different member type, but each pair has exactly two members. The member types of different tuple types are not the same, but a tuple can have any number of members. The number of members for each determined tuple type is fixed, but the number of members of a tuple type can be different from that of another tuple type.
To access a tuple member, you use a standard library function template called get.
2.
Operations supported by tuple
Tuple<t1,t2,..., tn> t;
T is a tuple, member digit n, the type I member is ti. All members are initialized with values.
Tuple<t1,t2,..., tn> t (v1,v2,..., VN);
T is a tuple, the member type is T1,T2,..., Tn, each member is initialized with the corresponding initial value VI. This constructor is explicit.
Make_tuple (v1,v2,..., vn);
Returns a tuple initialized with the given initial value. The type of the tuple is inferred from the type of the initial value
T1 = = T2
T1!= T2
When two tulpe have the same number of members corresponding to equal, two tuple are equal. These two operations are done using the member = = operator. Once a member is found to be unequal, the next member is not to be compared.
T1 RelOp T2
The tuple relational operation uses a dictionary order. Two tuple must have the same number of members. Use the < operator to compare the members of the T1 and the corresponding members of the T2.
Get<i> (t)
Returns a reference to the first member of T; if T is a left value, the result is a left reference; otherwise, the result is a reference to a right value. All members of tuple are public.
Tuple_size<tupletype>::value
A class template that can be initialized with a tuple type that has a public constexpr static data member named value with a type of size_t that represents the number of members in a given tuple type
Tuple_element<i,tupletype>::type
A class template that can be initialized with an integer constant and a tuple type that has a public member named type that represents the type of the specified member in the given tuple type.
17.2 Bitset Type
1.
Methods of initializing Bitset
Bitset<n> b;
B has n bits, each bit is 0, this constructor is a constexpr
Bitset<n> b (U);
b is the low n-bit copy of the unsigned long Long value U. If n is greater than the size of the unsigned long long, the high position in B that exceeds the unsigned long long is set to 0. This constructor is a constexpr
Bitset<n> b (S,pos,m,zero,one);
B is a copy of the string s starting from the position pos. M characters. S can only contain characters zero or one; if s contains any other characters, the constructor throws a invalid_argument exception. Characters are saved as zero and one in B respectively. POS defaults to 0,m defaults to ' 0 ' and one defaults to ' 1 ' by default for String::npos,zero.
Bitset<n> b (Cp,pos,m,zero,one);
The same as the previous constructor, but copies the characters from the array of characters pointed to by the CP. If M is not provided, the CP must point to a C-style string. If M is provided, there must be at least M zero or one character starting at the CP.
2.
Bitset operation
B.any ()
b whether there is a position of bits
B.all ()
Do all the elements in B have a bit?
B.none ()
There is no placement in B bits?
B.count ()
Number of bits in B
B.size ()
A constexpr function that returns the number of digits of B
B.text (POS)
Returns true if the bit of the POS position is bit, or false
B.set (POS,V)
B.set ()
Set the position at the POS point to the bool value of V. V defaults to True. If the argument is not passed, all positions in B are
B.reset (POS)
B.reset ()
Resets the position at POS to reset or resets all bits in B
B.FILP (POS)
B.FILP ()
Change the status of a bit at a POS position or change the state of each bit in B