In this tutorial we learn how elements of an RVec can be easily sorted and selected.
Author: Stefan Wunsch
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Wednesday, April 17, 2024 at 11:24 AM.
Because RVec implements an iterator, the class is fully compatible with the sorting algorithms in the standard library.
ROOT::RVecD v1{6., 4., 5.};
ROOT::RVecD v2(v1);
std::sort(v2.begin(), v2.end());
std::cout << "Sort vector " << v1 << ": " << v2 << std::endl;
Sort vector { 6, 4, 5 }: { 4, 5, 6 }
For convenience, ROOT implements helpers, e.g., to get a sorted copy of an RVec ...
auto v3 = Sort(v1);
std::cout << "Sort vector " << v1 << ": " << v3 << std::endl;
input_line_52:2:2: error: Syntax error auto v3 = Sort(v1); ^ FunctionDecl 0x7f5990fdb878 <input_line_52:1:1, line:5:1> line:1:6 __cling_Un1Qu320 'void (void *)' |-ParmVarDecl 0x7f5990fdb7c0 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f5990fe1f20 <col:43, line:5:1> | |-DeclStmt 0x7f5990fdbc68 <line:2:2, col:20> | | `-VarDecl 0x7f5990fdb990 <col:2, col:19> col:7 used v3 'auto' cinit | | `-CallExpr 0x7f5990fdbc40 <col:12, col:19> '<dependent type>' | | |-DeclRefExpr 0x7f5990fdbbe0 <col:12> '<dependent type>' lvalue Var 0x7f5990fdbb08 'Sort' '<dependent type>' | | `-DeclRefExpr 0x7f5990fdbc20 <col:17> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | |-CXXOperatorCallExpr 0x7f5990fe1ee0 <line:3:1, col:57> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f5990fe1ba0 <col:49> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | |-CXXOperatorCallExpr 0x7f5990fe1b00 <col:1, col:46> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f5990fe17c0 <col:43> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | | |-CXXOperatorCallExpr 0x7f5990fe1748 <col:1, col:38> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f5990fe1730 <col:35> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f5990fe1710 <col:35> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f5990fdfef8 <col:1, col:32> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | |-ImplicitCastExpr 0x7f5990fdfee0 <col:29> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f5990fdfec0 <col:29> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f599003eae8 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | |-CXXOperatorCallExpr 0x7f5990fdd518 <col:1, col:14> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | |-ImplicitCastExpr 0x7f5990fdd500 <col:11> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f5990fdd4e0 <col:11> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | | | |-DeclRefExpr 0x7f5990fdbcd0 <col:1, col:6> 'ostream':'std::basic_ostream<char>' lvalue Var 0x622cc98 'cout' 'ostream':'std::basic_ostream<char>' | | | | | | `-ImplicitCastExpr 0x7f5990fdd4c8 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | `-StringLiteral 0x7f5990fdbd00 <col:14> 'const char[13]' lvalue "Sort vector " | | | | | `-ImplicitCastExpr 0x7f5990fdfea8 <col:32> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | `-DeclRefExpr 0x7f5990fdd550 <col:32> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | `-ImplicitCastExpr 0x7f5990fe16f8 <col:38> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f5990fdff30 <col:38> 'const char[3]' lvalue ": " | | | `-DeclRefExpr 0x7f5990fe1780 <col:46> 'auto' lvalue Var 0x7f5990fdb990 'v3' 'auto' | | `-UnresolvedLookupExpr 0x7f5990fe1b58 <col:52, col:57> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x5f961b0 | `-NullStmt 0x7f5990fe1f18 <line:4:1> |-AnnotateAttr 0x7f5990fdba68 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f5990fdbb70 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" <<<NULL>>>
... or a reversed copy of an RVec.
auto v4 = Reverse(v1);
std::cout << "Reverse vector " << v1 << ": " << v4 << std::endl;
input_line_53:2:2: error: Syntax error auto v4 = Reverse(v1); ^ FunctionDecl 0x7f59923b3a00 <input_line_53:1:1, line:5:1> line:1:6 __cling_Un1Qu321 'void (void *)' |-ParmVarDecl 0x7f59923b3948 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f59923bad60 <col:43, line:5:1> | |-DeclStmt 0x7f59923b3df8 <line:2:2, col:23> | | `-VarDecl 0x7f59923b3b18 <col:2, col:22> col:7 used v4 'auto' cinit | | `-CallExpr 0x7f59923b3dd0 <col:12, col:22> '<dependent type>' | | |-DeclRefExpr 0x7f59923b3d70 <col:12> '<dependent type>' lvalue Var 0x7f59923b3c98 'Reverse' '<dependent type>' | | `-DeclRefExpr 0x7f59923b3db0 <col:20> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | |-CXXOperatorCallExpr 0x7f59923bad20 <line:3:1, col:60> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f59923ba9e0 <col:52> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | |-CXXOperatorCallExpr 0x7f59923ba940 <col:1, col:49> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f59923ba600 <col:46> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | | |-CXXOperatorCallExpr 0x7f59923ba588 <col:1, col:41> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f59923ba570 <col:38> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f59923ba550 <col:38> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f59923b8d38 <col:1, col:35> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | |-ImplicitCastExpr 0x7f59923b8d20 <col:32> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f59923b8d00 <col:32> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f599003eae8 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | |-CXXOperatorCallExpr 0x7f59923b6358 <col:1, col:14> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | |-ImplicitCastExpr 0x7f59923b6340 <col:11> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f59923b6320 <col:11> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | | | |-DeclRefExpr 0x7f59923b3e60 <col:1, col:6> 'ostream':'std::basic_ostream<char>' lvalue Var 0x622cc98 'cout' 'ostream':'std::basic_ostream<char>' | | | | | | `-ImplicitCastExpr 0x7f59923b6308 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | `-StringLiteral 0x7f59923b3ec8 <col:14> 'const char[16]' lvalue "Reverse vector " | | | | | `-ImplicitCastExpr 0x7f59923b8ce8 <col:35> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | `-DeclRefExpr 0x7f59923b6390 <col:35> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | `-ImplicitCastExpr 0x7f59923ba538 <col:41> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f59923b8d70 <col:41> 'const char[3]' lvalue ": " | | | `-DeclRefExpr 0x7f59923ba5c0 <col:49> 'auto' lvalue Var 0x7f59923b3b18 'v4' 'auto' | | `-UnresolvedLookupExpr 0x7f59923ba998 <col:55, col:60> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x5f961b0 | `-NullStmt 0x7f59923bad58 <line:4:1> |-AnnotateAttr 0x7f59923b3bf0 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f59923b3d00 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" <<<NULL>>>
Helpers are provided to get the indices that sort the vector and to select these indices from an RVec.
auto i = Argsort(v1);
std::cout << "Indices that sort the vector " << v1 << ": " << i << std::endl;
ROOT::RVecD v5{9., 7., 8.};
auto v6 = Take(v5, i);
std::cout << "Sort vector " << v5 << " respective to the previously"
<< " determined indices: " << v6 << std::endl;
input_line_54:2:2: error: Syntax error auto i = Argsort(v1); ^ FunctionDecl 0x7f59923bae90 <input_line_54:1:1, line:10:1> line:1:6 __cling_Un1Qu322 'void (void *)' |-ParmVarDecl 0x7f59923badd8 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f59923cb320 <col:43, line:10:1> | |-DeclStmt 0x7f59923bb288 <line:2:2, col:22> | | `-VarDecl 0x7f59923bafa8 <col:2, col:21> col:7 used i 'auto' cinit | | `-CallExpr 0x7f59923bb260 <col:11, col:21> '<dependent type>' | | |-DeclRefExpr 0x7f59923bb200 <col:11> '<dependent type>' lvalue Var 0x7f59923bb128 'Argsort' '<dependent type>' | | `-DeclRefExpr 0x7f59923bb240 <col:19> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | |-CXXOperatorCallExpr 0x7f59923c2580 <line:3:1, col:73> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f59923c2240 <col:65> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | |-CXXOperatorCallExpr 0x7f59923c21a0 <col:1, col:63> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f59923c1e60 <col:60> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | | |-CXXOperatorCallExpr 0x7f59923c1de8 <col:1, col:55> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f59923c1dd0 <col:52> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f59923c1db0 <col:52> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f59923c0598 <col:1, col:49> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | |-ImplicitCastExpr 0x7f59923c0580 <col:46> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f59923c0560 <col:46> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f599003eae8 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | |-CXXOperatorCallExpr 0x7f59923bdbb8 <col:1, col:14> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | |-ImplicitCastExpr 0x7f59923bdba0 <col:11> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f59923bdb80 <col:11> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | | | |-DeclRefExpr 0x7f59923bb2f0 <col:1, col:6> 'ostream':'std::basic_ostream<char>' lvalue Var 0x622cc98 'cout' 'ostream':'std::basic_ostream<char>' | | | | | | `-ImplicitCastExpr 0x7f59923bdb68 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | `-StringLiteral 0x7f59923bb398 <col:14> 'const char[30]' lvalue "Indices that sort the vector " | | | | | `-ImplicitCastExpr 0x7f59923c0548 <col:49> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | `-DeclRefExpr 0x7f59923bdbf0 <col:49> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | `-ImplicitCastExpr 0x7f59923c1d98 <col:55> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f59923c05d0 <col:55> 'const char[3]' lvalue ": " | | | `-DeclRefExpr 0x7f59923c1e20 <col:63> 'auto' lvalue Var 0x7f59923bafa8 'i' 'auto' | | `-UnresolvedLookupExpr 0x7f59923c21f8 <col:68, col:73> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x5f961b0 | |-DeclStmt 0x7f59923c2818 <line:5:1, col:27> | | `-VarDecl 0x7f59923c2608 <col:1, col:26> col:13 used v5 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' listinit destroyed | | `-ExprWithCleanups 0x7f59923c27e0 <col:13, col:26> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-CXXConstructExpr 0x7f59923c27b0 <col:13, col:26> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' 'void (std::initializer_list<double>)' list std::initializer_list | | `-CXXStdInitializerListExpr 0x7f59923c2798 <col:15, col:26> 'std::initializer_list<double>':'std::initializer_list<double>' | | `-MaterializeTemporaryExpr 0x7f59923c2780 <col:15, col:26> 'const double[3]' xvalue | | `-InitListExpr 0x7f59923c2728 <col:15, col:26> 'const double[3]' | | |-FloatingLiteral 0x7f59923c2670 <col:16> 'double' 9.000000e+00 | | |-FloatingLiteral 0x7f59923c2690 <col:20> 'double' 7.000000e+00 | | `-FloatingLiteral 0x7f59923c26b0 <col:24> 'double' 8.000000e+00 | |-DeclStmt 0x7f59923c2b50 <line:6:1, col:22> | | `-VarDecl 0x7f59923c2878 <col:1, col:21> col:6 used v6 'auto' cinit | | `-CallExpr 0x7f59923c2b20 <col:11, col:21> '<dependent type>' | | |-DeclRefExpr 0x7f59923c2aa0 <col:11> '<dependent type>' lvalue Var 0x7f59923c29c8 'Take' '<dependent type>' | | |-DeclRefExpr 0x7f59923c2ae0 <col:16> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x7f59923c2608 'v5' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-DeclRefExpr 0x7f59923c2b00 <col:20> 'auto' lvalue Var 0x7f59923bafa8 'i' 'auto' | |-CXXOperatorCallExpr 0x7f59923cb2e0 <line:7:1, line:8:52> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f59923cafa0 <col:44> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | |-CXXOperatorCallExpr 0x7f59923caf00 <line:7:1, line:8:41> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f59923cabc0 <col:38> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | | |-CXXOperatorCallExpr 0x7f59923cab48 <line:7:1, line:8:14> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f59923cab30 <col:11> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f59923cab10 <col:11> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f59923c8648 <line:7:1, col:38> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | |-ImplicitCastExpr 0x7f59923c8630 <col:35> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f59923c8610 <col:35> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | | |-CXXOperatorCallExpr 0x7f59923c6dd8 <col:1, col:32> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | | |-ImplicitCastExpr 0x7f59923c6dc0 <col:29> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f59923c6da0 <col:29> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f599003eae8 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | | |-CXXOperatorCallExpr 0x7f59923c43f8 <col:1, col:14> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | | |-ImplicitCastExpr 0x7f59923c43e0 <col:11> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | | `-DeclRefExpr 0x7f59923c43c0 <col:11> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | | | | |-DeclRefExpr 0x7f59923c2bb8 <col:1, col:6> 'ostream':'std::basic_ostream<char>' lvalue Var 0x622cc98 'cout' 'ostream':'std::basic_ostream<char>' | | | | | | | `-ImplicitCastExpr 0x7f59923c43a8 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | | `-StringLiteral 0x7f59923c2be8 <col:14> 'const char[13]' lvalue "Sort vector " | | | | | | `-ImplicitCastExpr 0x7f59923c6d88 <col:32> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | | `-DeclRefExpr 0x7f59923c4430 <col:32> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x7f59923c2608 'v5' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | | `-ImplicitCastExpr 0x7f59923c85f8 <col:38> 'const char *' <ArrayToPointerDecay> | | | | | `-StringLiteral 0x7f59923c6e10 <col:38> 'const char[30]' lvalue " respective to the previously" | | | | `-ImplicitCastExpr 0x7f59923caaf8 <line:8:14> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f59923c8680 <col:14> 'const char[22]' lvalue " determined indices: " | | | `-DeclRefExpr 0x7f59923cab80 <col:41> 'auto' lvalue Var 0x7f59923c2878 'v6' 'auto' | | `-UnresolvedLookupExpr 0x7f59923caf58 <col:47, col:52> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x5f961b0 | `-NullStmt 0x7f59923cb318 <line:9:1> |-AnnotateAttr 0x7f59923bb080 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f59923bb190 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f59923c2950 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f59923c2a30 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" <<<NULL>>>
Take can also be used to get the first or last elements of an RVec.
auto v7 = Take(v1, 2);
auto v8 = Take(v1, -2);
std::cout << "Take the two first and last elements of vector " << v1
<< ": " << v7 << ", " << v8 << std::endl;
input_line_55:2:2: error: Syntax error auto v7 = Take(v1, 2); ^ FunctionDecl 0x7f59923cb468 <input_line_55:1:1, line:7:1> line:1:6 __cling_Un1Qu323 'void (void *)' |-ParmVarDecl 0x7f59923cb3b0 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f59923d3840 <col:43, line:7:1> | |-DeclStmt 0x7f59923cb880 <line:2:2, col:23> | | `-VarDecl 0x7f59923cb580 <col:2, col:22> col:7 used v7 'auto' cinit | | `-CallExpr 0x7f59923cb850 <col:12, col:22> '<dependent type>' | | |-DeclRefExpr 0x7f59923cb7d0 <col:12> '<dependent type>' lvalue Var 0x7f59923cb6f8 'Take' '<dependent type>' | | |-DeclRefExpr 0x7f59923cb810 <col:17> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-IntegerLiteral 0x7f59923cb830 <col:21> 'int' 2 | |-DeclStmt 0x7f59923cbbc8 <line:3:1, col:23> | | `-VarDecl 0x7f59923cb8e0 <col:1, col:22> col:6 used v8 'auto' cinit | | `-CallExpr 0x7f59923cbb98 <col:11, col:22> '<dependent type>' | | |-DeclRefExpr 0x7f59923cbb00 <col:11> '<dependent type>' lvalue Var 0x7f59923cba28 'Take' '<dependent type>' | | |-DeclRefExpr 0x7f59923cbb40 <col:16> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-UnaryOperator 0x7f59923cbb80 <col:20, col:21> 'int' prefix '-' | | `-IntegerLiteral 0x7f59923cbb60 <col:21> 'int' 2 | |-CXXOperatorCallExpr 0x7f59923d3800 <line:4:1, line:5:47> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f59923d34c0 <col:39> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | |-CXXOperatorCallExpr 0x7f59923d3420 <line:4:1, line:5:36> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f59923d30e0 <col:33> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | | |-CXXOperatorCallExpr 0x7f59923d3068 <line:4:1, line:5:28> '<dependent type>' '<<' | | | | |-UnresolvedLookupExpr 0x7f59923d2d28 <col:25> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | | | |-CXXOperatorCallExpr 0x7f59923d2cd0 <line:4:1, line:5:22> '<dependent type>' '<<' | | | | | |-UnresolvedLookupExpr 0x7f59923d2990 <col:19> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | | | | |-CXXOperatorCallExpr 0x7f59923d2918 <line:4:1, line:5:14> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | |-ImplicitCastExpr 0x7f59923d2900 <col:11> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f59923d28e0 <col:11> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | | | |-CXXOperatorCallExpr 0x7f59923d10c8 <line:4:1, col:67> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | | | |-ImplicitCastExpr 0x7f59923d10b0 <col:64> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | | | `-DeclRefExpr 0x7f59923d1090 <col:64> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f599003eae8 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | | | |-CXXOperatorCallExpr 0x7f59923ce6e8 <col:1, col:14> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | | | |-ImplicitCastExpr 0x7f59923ce6d0 <col:11> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | | | `-DeclRefExpr 0x7f59923ce6b0 <col:11> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | | | | | |-DeclRefExpr 0x7f59923cbc30 <col:1, col:6> 'ostream':'std::basic_ostream<char>' lvalue Var 0x622cc98 'cout' 'ostream':'std::basic_ostream<char>' | | | | | | | | `-ImplicitCastExpr 0x7f59923ce698 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | | | `-StringLiteral 0x7f59923cbcd8 <col:14> 'const char[48]' lvalue "Take the two first and last elements of vector " | | | | | | | `-ImplicitCastExpr 0x7f59923d1078 <col:67> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | | | `-DeclRefExpr 0x7f59923ce720 <col:67> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | | | `-ImplicitCastExpr 0x7f59923d28c8 <line:5:14> 'const char *' <ArrayToPointerDecay> | | | | | | `-StringLiteral 0x7f59923d1100 <col:14> 'const char[3]' lvalue ": " | | | | | `-DeclRefExpr 0x7f59923d2950 <col:22> 'auto' lvalue Var 0x7f59923cb580 'v7' 'auto' | | | | `-StringLiteral 0x7f59923d2d08 <col:28> 'const char[3]' lvalue ", " | | | `-DeclRefExpr 0x7f59923d30a0 <col:36> 'auto' lvalue Var 0x7f59923cb8e0 'v8' 'auto' | | `-UnresolvedLookupExpr 0x7f59923d3478 <col:42, col:47> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x5f961b0 | `-NullStmt 0x7f59923d3838 <line:6:1> |-AnnotateAttr 0x7f59923cb658 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f59923cb760 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f59923cb9b8 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f59923cba90 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" <<<NULL>>>
Because the helpers return a copy of the input, you can chain the operations conveniently.
auto v9 = Reverse(Take(Sort(v1), -2));
std::cout << "Sort the vector " << v1 << ", take the two last elements and "
<< "reverse the selection: " << v9 << std::endl;
input_line_56:2:2: error: Syntax error auto v9 = Reverse(Take(Sort(v1), -2)); ^ FunctionDecl 0x7f59923d3978 <input_line_56:1:1, line:6:1> line:1:6 __cling_Un1Qu324 'void (void *)' |-ParmVarDecl 0x7f59923d38c0 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f59923deab0 <col:43, line:6:1> | |-DeclStmt 0x7f59923d41f8 <line:2:2, col:39> | | `-VarDecl 0x7f59923d3a90 <col:2, col:38> col:7 used v9 'auto' cinit | | `-CallExpr 0x7f59923d41d0 <col:12, col:38> '<dependent type>' | | |-DeclRefExpr 0x7f59923d3ce0 <col:12> '<dependent type>' lvalue Var 0x7f59923d3c08 'Reverse' '<dependent type>' | | `-CallExpr 0x7f59923d41a0 <col:20, col:37> '<dependent type>' | | |-DeclRefExpr 0x7f59923d3ee0 <col:20> '<dependent type>' lvalue Var 0x7f59923d3e08 'Take' '<dependent type>' | | |-CallExpr 0x7f59923d4140 <col:25, col:32> '<dependent type>' | | | |-DeclRefExpr 0x7f59923d40e0 <col:25> '<dependent type>' lvalue Var 0x7f59923d4008 'Sort' '<dependent type>' | | | `-DeclRefExpr 0x7f59923d4120 <col:30> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-UnaryOperator 0x7f59923d4188 <col:35, col:36> 'int' prefix '-' | | `-IntegerLiteral 0x7f59923d4168 <col:36> 'int' 2 | |-CXXOperatorCallExpr 0x7f59923dea70 <line:3:1, line:4:54> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f59923de730 <col:46> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | |-CXXOperatorCallExpr 0x7f59923de690 <line:3:1, line:4:43> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f59923de350 <col:40> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x6a63bb8 0x54fd618 0x54fcf78 0x6a61178 0x6a61400 0x6a61690 0x6a61920 0x6a61bb0 0x6a61e40 0x6a620d0 0x6a62360 0x6a625f0 0x6a62880 0x6a62b10 0x6a62da0 0x6a63030 0x6a632c0 0x6a63588 0x6a670a8 0x6a69718 0x6a709b8 0x6a718a8 0x6a7ed68 0x6a7f088 0x6a894d8 0x6a8a5d8 0x6a8b918 0x6a8cce8 0x6a8e028 0x6a8f368 0x6a91410 0x6cd8a68 0x6cda448 0x6eb4f08 0x5a55390 0x5a6e898 0x5e9e568 0x5f48560 0x5f921b8 0x5f92858 0x5f92ef8 0x5f93588 0x5f93b90 0x5f941a0 0x5f9b410 0x5f94f20 0x5f95530 0x5f95b70 0x5f99ff8 0x5fe8e90 0x5c90770 0x610d418 0x61b14f8 0x620bed8 0x620cf78 0x620dff8 0x620f568 0x6210678 0x62116f8 0x6213610 0x62146f0 0x6308078 0x633d8c8 0x6314708 0x6315668 0x63165c8 0x6317958 0x6360b28 0x6318048 0x6376948 0x6318fa8 0x6319f08 0x631ae68 0x63220d8 0x6347538 0x6349b60 0x634c238 0x6357028 0x6359cf8 0x635d4e8 0x636a648 0x636d1a0 0x63714c8 0x6373e88 0x6383a58 0x63887c8 0x638d468 0x67d37b0 0x650a828 0x650b4c0 0x650bf28 0x650c988 0x650d478 0x65bf5f0 0x65c0050 0x65c0a50 | | | |-CXXOperatorCallExpr 0x7f59923de2d8 <line:3:1, line:4:14> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f59923de2c0 <col:11> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f59923de2a0 <col:11> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f59923db678 <line:3:1, col:42> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | |-ImplicitCastExpr 0x7f59923db660 <col:39> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f59923db640 <col:39> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | | |-CXXOperatorCallExpr 0x7f59923d9108 <col:1, col:36> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | | |-ImplicitCastExpr 0x7f59923d90f0 <col:33> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f59923d90d0 <col:33> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f599003eae8 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | | |-CXXOperatorCallExpr 0x7f59923d6728 <col:1, col:14> 'basic_ostream<char, char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | | |-ImplicitCastExpr 0x7f59923d6710 <col:11> 'basic_ostream<char, char_traits<char> > &(*)(basic_ostream<char, char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | | `-DeclRefExpr 0x7f59923d66f0 <col:11> 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' lvalue Function 0x7f5990033708 'operator<<' 'basic_ostream<char, char_traits<char> > &(basic_ostream<char, char_traits<char> > &, const char *)' | | | | | | | |-DeclRefExpr 0x7f59923d4260 <col:1, col:6> 'ostream':'std::basic_ostream<char>' lvalue Var 0x622cc98 'cout' 'ostream':'std::basic_ostream<char>' | | | | | | | `-ImplicitCastExpr 0x7f59923d66d8 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | | `-StringLiteral 0x7f59923d4290 <col:14> 'const char[17]' lvalue "Sort the vector " | | | | | | `-ImplicitCastExpr 0x7f59923d90b8 <col:36> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | | `-DeclRefExpr 0x7f59923d6760 <col:36> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x94e21a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | | `-ImplicitCastExpr 0x7f59923db628 <col:42> 'const char *' <ArrayToPointerDecay> | | | | | `-StringLiteral 0x7f59923d91b8 <col:42> 'const char[34]' lvalue ", take the two last elements and " | | | | `-ImplicitCastExpr 0x7f59923de288 <line:4:14> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f59923db728 <col:14> 'const char[24]' lvalue "reverse the selection: " | | | `-DeclRefExpr 0x7f59923de310 <col:43> 'auto' lvalue Var 0x7f59923d3a90 'v9' 'auto' | | `-UnresolvedLookupExpr 0x7f59923de6e8 <col:49, col:54> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x5f961b0 | `-NullStmt 0x7f59923deaa8 <line:5:1> |-AnnotateAttr 0x7f59923d3b68 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f59923d3c70 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f59923d3d90 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f59923d3e70 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f59923d3f90 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f59923d4070 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" <<<NULL>>>