本文整理汇总了C++中ValueArray::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ ValueArray::Set方法的具体用法?C++ ValueArray::Set怎么用?C++ ValueArray::Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValueArray
的用法示例。
在下文中一共展示了ValueArray::Set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TupleTutorial
void TupleTutorial()
{
/// . Tuples
/// Template class `Tuple` allows combining 2-4 values with
/// different types. These are principally similar to `std::tuple`, with some advantages.
/// Unlike `std::tuple`, individual elements are directly accessible as member variables
/// `a`..`d`, `Tuple` supports persistent storage patterns (`Serialize`, `Jsonize`, `Xmlize`), hash
/// code (`GetHashValue`), conversion to `String` and Value conversions.
/// To create a `Tuple` value, you can use the `MakeTuple` function.
Tuple<int, String, String> x = MakeTuple(12, "hello", "world");
/// Individual values are accessible as members `a` .. `d`:
DUMP(x.a);
DUMP(x.b);
DUMP(x.c);
/// Or using `Get`:
DUMP(x.Get<1>());
DUMP(x.Get<int>());
/// As long as all individual types have conversion to `String` (`AsString`), the tuple also
/// has such conversion and thus can e.g. be easily logged:
DUMP(x);
/// As long as individual types have defined `GetHashValue`, so does `Tuple`:
DUMP(GetHashValue(x));
/// As long as individual types have defined `operator==`, `Tuple` has defined `operator==`
/// and `operator!=`:
Tuple<int, String, String> y = x;
DUMP(x == y);
DUMP(x != y);
y.a++;
DUMP(x == y);
DUMP(x != y);
/// As long as all individual types have defined `SgnCompare`,
/// Tuple has SgnCompare, Compare method and operators <, <=, >, >=:
DUMP(x.Compare(y));
DUMP(SgnCompare(x, y));
DUMP(x < y);
/// GetCount returns the width of `Tuple`:
DUMP(x.GetCount());
/// Elements that are directly convertible with `Value` can be 'Get'/'Set':
for(int i = 0; i < x.GetCount(); i++)
DUMP(x.Get(i));
///
x.Set(1, "Hi");
DUMP(x);
/// As long as all individual types are convertible with `Value`, you can convert Tuple to
/// `ValueArray` and back:
ValueArray va = x.GetArray();
DUMP(va);
va.Set(2, "Joe");
x.SetArray(va);
/// It is OK to assign `Tuple` to `Tuple` with different individual types, as long as types
/// are directly convertible:
Tuple<double, String, String> d = x;
DUMP(d);
/// Tie can be used to assign tuple to l-values:
int i;
String s1, s2;
Tie(i, s1, s2) = x;
DUMP(i);
DUMP(s1);
DUMP(s2);
/// U++ Tuples are carefully designed as POD type, which allows POD arrays to be intialized
/// with classic C style:
static Tuple2<int, const char *> map[] = {
{ 1, "one" },
{ 2, "one" },
{ 3, "one" },
};
//.........这里部分代码省略.........