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 Tuesday, March 28, 2023 at 10:03 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 0x7f20aad0d618 <input_line_52:1:1, line:5:1> line:1:6 __cling_Un1Qu320 'void (void *)' |-ParmVarDecl 0x7f20aad0d560 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f20aad13528 <col:43, line:5:1> | |-DeclStmt 0x7f20aad0d9d8 <line:2:2, col:20> | | `-VarDecl 0x7f20aad0d720 <col:2, col:19> col:7 used v3 'auto' cinit | | `-CallExpr 0x7f20aad0d9b0 <col:12, col:19> '<dependent type>' | | |-DeclRefExpr 0x7f20aad0d950 <col:12> '<dependent type>' lvalue Var 0x7f20aad0d888 'Sort' '<dependent type>' | | `-DeclRefExpr 0x7f20aad0d990 <col:17> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | |-CXXOperatorCallExpr 0x7f20aad134e8 <line:3:1, col:57> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f20aad131a0 <col:49> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | |-CXXOperatorCallExpr 0x7f20aad13100 <col:1, col:46> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f20aad12db8 <col:43> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | | |-CXXOperatorCallExpr 0x7f20aad12d40 <col:1, col:38> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f20aad12d28 <col:35> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f20aad12d08 <col:35> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f20aad117b8 <col:1, col:32> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | |-ImplicitCastExpr 0x7f20aad117a0 <col:29> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f20aad11780 <col:29> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f20a829b218 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | |-CXXOperatorCallExpr 0x7f20aad0efc0 <col:1, col:14> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | |-ImplicitCastExpr 0x7f20aad0efa8 <col:11> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f20aad0ef88 <col:11> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | | | |-DeclRefExpr 0x7f20aad0da40 <col:1, col:6> 'std::ostream':'std::basic_ostream<char>' lvalue Var 0x45f3bb0 'cout' 'std::ostream':'std::basic_ostream<char>' | | | | | | `-ImplicitCastExpr 0x7f20aad0ef70 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | `-StringLiteral 0x7f20aad0da70 <col:14> 'const char [13]' lvalue "Sort vector " | | | | | `-ImplicitCastExpr 0x7f20aad11768 <col:32> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | `-DeclRefExpr 0x7f20aad0eff8 <col:32> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | `-ImplicitCastExpr 0x7f20aad12cf0 <col:38> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f20aad117f0 <col:38> 'const char [3]' lvalue ": " | | | `-DeclRefExpr 0x7f20aad12d78 <col:46> 'auto' lvalue Var 0x7f20aad0d720 'v3' 'auto' | | `-UnresolvedLookupExpr 0x7f20aad13158 <col:52, col:57> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x43a1658 | `-NullStmt 0x7f20aad13520 <line:4:1> |-AnnotateAttr 0x7f20aad0d7f8 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f20aad0d8f0 <<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 0x7f20ab95a378 <input_line_53:1:1, line:5:1> line:1:6 __cling_Un1Qu321 'void (void *)' |-ParmVarDecl 0x7f20ab95a2c0 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f20ab960708 <col:43, line:5:1> | |-DeclStmt 0x7f20ab95a738 <line:2:2, col:23> | | `-VarDecl 0x7f20ab95a480 <col:2, col:22> col:7 used v4 'auto' cinit | | `-CallExpr 0x7f20ab95a710 <col:12, col:22> '<dependent type>' | | |-DeclRefExpr 0x7f20ab95a6b0 <col:12> '<dependent type>' lvalue Var 0x7f20ab95a5e8 'Reverse' '<dependent type>' | | `-DeclRefExpr 0x7f20ab95a6f0 <col:20> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | |-CXXOperatorCallExpr 0x7f20ab9606c8 <line:3:1, col:60> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f20ab960380 <col:52> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | |-CXXOperatorCallExpr 0x7f20ab9602e0 <col:1, col:49> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f20ab95ff98 <col:46> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | | |-CXXOperatorCallExpr 0x7f20ab95ff20 <col:1, col:41> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f20ab95ff08 <col:38> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f20ab95fee8 <col:38> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f20ab95e998 <col:1, col:35> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | |-ImplicitCastExpr 0x7f20ab95e980 <col:32> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f20ab95e960 <col:32> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f20a829b218 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | |-CXXOperatorCallExpr 0x7f20ab95c1a0 <col:1, col:14> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | |-ImplicitCastExpr 0x7f20ab95c188 <col:11> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f20ab95c168 <col:11> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | | | |-DeclRefExpr 0x7f20ab95a7a0 <col:1, col:6> 'std::ostream':'std::basic_ostream<char>' lvalue Var 0x45f3bb0 'cout' 'std::ostream':'std::basic_ostream<char>' | | | | | | `-ImplicitCastExpr 0x7f20ab95c150 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | `-StringLiteral 0x7f20ab95a808 <col:14> 'const char [16]' lvalue "Reverse vector " | | | | | `-ImplicitCastExpr 0x7f20ab95e948 <col:35> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | `-DeclRefExpr 0x7f20ab95c1d8 <col:35> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | `-ImplicitCastExpr 0x7f20ab95fed0 <col:41> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f20ab95e9d0 <col:41> 'const char [3]' lvalue ": " | | | `-DeclRefExpr 0x7f20ab95ff58 <col:49> 'auto' lvalue Var 0x7f20ab95a480 'v4' 'auto' | | `-UnresolvedLookupExpr 0x7f20ab960338 <col:55, col:60> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x43a1658 | `-NullStmt 0x7f20ab960700 <line:4:1> |-AnnotateAttr 0x7f20ab95a558 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f20ab95a650 <<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 0x7f20ab960838 <input_line_54:1:1, line:10:1> line:1:6 __cling_Un1Qu322 'void (void *)' |-ParmVarDecl 0x7f20ab960780 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f20ab96e678 <col:43, line:10:1> | |-DeclStmt 0x7f20ab960bf8 <line:2:2, col:22> | | `-VarDecl 0x7f20ab960940 <col:2, col:21> col:7 used i 'auto' cinit | | `-CallExpr 0x7f20ab960bd0 <col:11, col:21> '<dependent type>' | | |-DeclRefExpr 0x7f20ab960b70 <col:11> '<dependent type>' lvalue Var 0x7f20ab960aa8 'Argsort' '<dependent type>' | | `-DeclRefExpr 0x7f20ab960bb0 <col:19> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | |-CXXOperatorCallExpr 0x7f20ab966b98 <line:3:1, col:73> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f20ab966850 <col:65> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | |-CXXOperatorCallExpr 0x7f20ab9667b0 <col:1, col:63> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f20ab966468 <col:60> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | | |-CXXOperatorCallExpr 0x7f20ab9663f0 <col:1, col:55> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f20ab9663d8 <col:52> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f20ab9663b8 <col:52> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f20ab964e68 <col:1, col:49> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | |-ImplicitCastExpr 0x7f20ab964e50 <col:46> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f20ab964e30 <col:46> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f20a829b218 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | |-CXXOperatorCallExpr 0x7f20ab962670 <col:1, col:14> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | |-ImplicitCastExpr 0x7f20ab962658 <col:11> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f20ab962638 <col:11> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | | | |-DeclRefExpr 0x7f20ab960c60 <col:1, col:6> 'std::ostream':'std::basic_ostream<char>' lvalue Var 0x45f3bb0 'cout' 'std::ostream':'std::basic_ostream<char>' | | | | | | `-ImplicitCastExpr 0x7f20ab962620 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | `-StringLiteral 0x7f20ab960cc8 <col:14> 'const char [30]' lvalue "Indices that sort the vector " | | | | | `-ImplicitCastExpr 0x7f20ab964e18 <col:49> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | `-DeclRefExpr 0x7f20ab9626a8 <col:49> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | `-ImplicitCastExpr 0x7f20ab9663a0 <col:55> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f20ab964ea0 <col:55> 'const char [3]' lvalue ": " | | | `-DeclRefExpr 0x7f20ab966428 <col:63> 'auto' lvalue Var 0x7f20ab960940 'i' 'auto' | | `-UnresolvedLookupExpr 0x7f20ab966808 <col:68, col:73> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x43a1658 | |-DeclStmt 0x7f20ab966e30 <line:5:1, col:27> | | `-VarDecl 0x7f20ab966c20 <col:1, col:26> col:13 used v5 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' listinit destroyed | | `-ExprWithCleanups 0x7f20ab966df8 <col:13, col:26> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-CXXConstructExpr 0x7f20ab966dc8 <col:13, col:26> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' 'void (std::initializer_list<double>)' list std::initializer_list | | `-CXXStdInitializerListExpr 0x7f20ab966db0 <col:15, col:26> 'std::initializer_list<double>':'std::initializer_list<double>' | | `-MaterializeTemporaryExpr 0x7f20ab966d98 <col:15, col:26> 'const double [3]' xvalue | | `-InitListExpr 0x7f20ab966d40 <col:15, col:26> 'const double [3]' | | |-FloatingLiteral 0x7f20ab966c88 <col:16> 'double' 9.000000e+00 | | |-FloatingLiteral 0x7f20ab966ca8 <col:20> 'double' 7.000000e+00 | | `-FloatingLiteral 0x7f20ab966cc8 <col:24> 'double' 8.000000e+00 | |-DeclStmt 0x7f20ab967140 <line:6:1, col:22> | | `-VarDecl 0x7f20ab966e88 <col:1, col:21> col:6 used v6 'auto' cinit | | `-CallExpr 0x7f20ab967110 <col:11, col:21> '<dependent type>' | | |-DeclRefExpr 0x7f20ab967090 <col:11> '<dependent type>' lvalue Var 0x7f20ab966fc8 'Take' '<dependent type>' | | |-DeclRefExpr 0x7f20ab9670d0 <col:16> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x7f20ab966c20 'v5' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-DeclRefExpr 0x7f20ab9670f0 <col:20> 'auto' lvalue Var 0x7f20ab960940 'i' 'auto' | |-CXXOperatorCallExpr 0x7f20ab96e638 <line:7:1, line:8:52> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f20ab96e2f0 <col:44> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | |-CXXOperatorCallExpr 0x7f20ab96e250 <line:7:1, line:8:41> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f20ab96df08 <col:38> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | | |-CXXOperatorCallExpr 0x7f20ab96de90 <line:7:1, line:8:14> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f20ab96de78 <col:11> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f20ab96de58 <col:11> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f20ab96c4c0 <line:7:1, col:38> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | |-ImplicitCastExpr 0x7f20ab96c4a8 <col:35> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f20ab96c488 <col:35> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | | |-CXXOperatorCallExpr 0x7f20ab96af28 <col:1, col:32> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | | |-ImplicitCastExpr 0x7f20ab96af10 <col:29> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f20ab96aef0 <col:29> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f20a829b218 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | | |-CXXOperatorCallExpr 0x7f20ab968730 <col:1, col:14> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | | |-ImplicitCastExpr 0x7f20ab968718 <col:11> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | | `-DeclRefExpr 0x7f20ab9686f8 <col:11> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | | | | |-DeclRefExpr 0x7f20ab9671a8 <col:1, col:6> 'std::ostream':'std::basic_ostream<char>' lvalue Var 0x45f3bb0 'cout' 'std::ostream':'std::basic_ostream<char>' | | | | | | | `-ImplicitCastExpr 0x7f20ab9686e0 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | | `-StringLiteral 0x7f20ab9671d8 <col:14> 'const char [13]' lvalue "Sort vector " | | | | | | `-ImplicitCastExpr 0x7f20ab96aed8 <col:32> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | | `-DeclRefExpr 0x7f20ab968768 <col:32> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0x7f20ab966c20 'v5' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | | `-ImplicitCastExpr 0x7f20ab96c470 <col:38> 'const char *' <ArrayToPointerDecay> | | | | | `-StringLiteral 0x7f20ab96af60 <col:38> 'const char [30]' lvalue " respective to the previously" | | | | `-ImplicitCastExpr 0x7f20ab96de40 <line:8:14> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f20ab96c4f8 <col:14> 'const char [22]' lvalue " determined indices: " | | | `-DeclRefExpr 0x7f20ab96dec8 <col:41> 'auto' lvalue Var 0x7f20ab966e88 'v6' 'auto' | | `-UnresolvedLookupExpr 0x7f20ab96e2a8 <col:47, col:52> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x43a1658 | `-NullStmt 0x7f20ab96e670 <line:9:1> |-AnnotateAttr 0x7f20ab960a18 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f20ab960b10 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f20ab966f60 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f20ab967030 <<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 0x7f20ab96e7c0 <input_line_55:1:1, line:7:1> line:1:6 __cling_Un1Qu323 'void (void *)' |-ParmVarDecl 0x7f20ab96e708 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f20ab975f68 <col:43, line:7:1> | |-DeclStmt 0x7f20ab96ebb0 <line:2:2, col:23> | | `-VarDecl 0x7f20ab96e8c8 <col:2, col:22> col:7 used v7 'auto' cinit | | `-CallExpr 0x7f20ab96eb80 <col:12, col:22> '<dependent type>' | | |-DeclRefExpr 0x7f20ab96eb00 <col:12> '<dependent type>' lvalue Var 0x7f20ab96ea38 'Take' '<dependent type>' | | |-DeclRefExpr 0x7f20ab96eb40 <col:17> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-IntegerLiteral 0x7f20ab96eb60 <col:21> 'int' 2 | |-DeclStmt 0x7f20ab96eed8 <line:3:1, col:23> | | `-VarDecl 0x7f20ab96ec08 <col:1, col:22> col:6 used v8 'auto' cinit | | `-CallExpr 0x7f20ab96eea8 <col:11, col:22> '<dependent type>' | | |-DeclRefExpr 0x7f20ab96ee10 <col:11> '<dependent type>' lvalue Var 0x7f20ab96ed48 'Take' '<dependent type>' | | |-DeclRefExpr 0x7f20ab96ee50 <col:16> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-UnaryOperator 0x7f20ab96ee90 <col:20, col:21> 'int' prefix '-' | | `-IntegerLiteral 0x7f20ab96ee70 <col:21> 'int' 2 | |-CXXOperatorCallExpr 0x7f20ab975f28 <line:4:1, line:5:47> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f20ab975be0 <col:39> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | |-CXXOperatorCallExpr 0x7f20ab975b40 <line:4:1, line:5:36> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f20ab9757f8 <col:33> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | | |-CXXOperatorCallExpr 0x7f20ab975780 <line:4:1, line:5:28> '<dependent type>' '<<' | | | | |-UnresolvedLookupExpr 0x7f20ab975438 <col:25> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | | | |-CXXOperatorCallExpr 0x7f20ab9753e0 <line:4:1, line:5:22> '<dependent type>' '<<' | | | | | |-UnresolvedLookupExpr 0x7f20ab975098 <col:19> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | | | | |-CXXOperatorCallExpr 0x7f20ab975020 <line:4:1, line:5:14> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | |-ImplicitCastExpr 0x7f20ab975008 <col:11> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f20ab974fe8 <col:11> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | | | |-CXXOperatorCallExpr 0x7f20ab973a98 <line:4:1, col:67> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | | | |-ImplicitCastExpr 0x7f20ab973a80 <col:64> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | | | `-DeclRefExpr 0x7f20ab973a60 <col:64> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f20a829b218 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | | | |-CXXOperatorCallExpr 0x7f20ab9712a0 <col:1, col:14> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | | | |-ImplicitCastExpr 0x7f20ab971288 <col:11> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | | | `-DeclRefExpr 0x7f20ab971268 <col:11> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | | | | | |-DeclRefExpr 0x7f20ab96ef40 <col:1, col:6> 'std::ostream':'std::basic_ostream<char>' lvalue Var 0x45f3bb0 'cout' 'std::ostream':'std::basic_ostream<char>' | | | | | | | | `-ImplicitCastExpr 0x7f20ab971250 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | | | `-StringLiteral 0x7f20ab96efa8 <col:14> 'const char [48]' lvalue "Take the two first and last elements of vector " | | | | | | | `-ImplicitCastExpr 0x7f20ab973a48 <col:67> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | | | `-DeclRefExpr 0x7f20ab9712d8 <col:67> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | | | `-ImplicitCastExpr 0x7f20ab974fd0 <line:5:14> 'const char *' <ArrayToPointerDecay> | | | | | | `-StringLiteral 0x7f20ab973ad0 <col:14> 'const char [3]' lvalue ": " | | | | | `-DeclRefExpr 0x7f20ab975058 <col:22> 'auto' lvalue Var 0x7f20ab96e8c8 'v7' 'auto' | | | | `-StringLiteral 0x7f20ab975418 <col:28> 'const char [3]' lvalue ", " | | | `-DeclRefExpr 0x7f20ab9757b8 <col:36> 'auto' lvalue Var 0x7f20ab96ec08 'v8' 'auto' | | `-UnresolvedLookupExpr 0x7f20ab975b98 <col:42, col:47> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x43a1658 | `-NullStmt 0x7f20ab975f60 <line:6:1> |-AnnotateAttr 0x7f20ab96e9a0 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f20ab96eaa0 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f20ab96ece0 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f20ab96edb0 <<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 0x7f20ab9760a0 <input_line_56:1:1, line:6:1> line:1:6 __cling_Un1Qu324 'void (void *)' |-ParmVarDecl 0x7f20ab975fe8 <col:23, col:29> col:29 vpClingValue 'void *' |-CompoundStmt 0x7f20ab97e6b8 <col:43, line:6:1> | |-DeclStmt 0x7f20ab9768b8 <line:2:2, col:39> | | `-VarDecl 0x7f20ab9761a8 <col:2, col:38> col:7 used v9 'auto' cinit | | `-CallExpr 0x7f20ab976890 <col:12, col:38> '<dependent type>' | | |-DeclRefExpr 0x7f20ab9763e0 <col:12> '<dependent type>' lvalue Var 0x7f20ab976318 'Reverse' '<dependent type>' | | `-CallExpr 0x7f20ab976860 <col:20, col:37> '<dependent type>' | | |-DeclRefExpr 0x7f20ab9765c0 <col:20> '<dependent type>' lvalue Var 0x7f20ab9764f8 'Take' '<dependent type>' | | |-CallExpr 0x7f20ab976800 <col:25, col:32> '<dependent type>' | | | |-DeclRefExpr 0x7f20ab9767a0 <col:25> '<dependent type>' lvalue Var 0x7f20ab9766d8 'Sort' '<dependent type>' | | | `-DeclRefExpr 0x7f20ab9767e0 <col:30> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | `-UnaryOperator 0x7f20ab976848 <col:35, col:36> 'int' prefix '-' | | `-IntegerLiteral 0x7f20ab976828 <col:36> 'int' 2 | |-CXXOperatorCallExpr 0x7f20ab97e678 <line:3:1, line:4:54> '<dependent type>' '<<' | | |-UnresolvedLookupExpr 0x7f20ab97e330 <col:46> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | |-CXXOperatorCallExpr 0x7f20ab97e290 <line:3:1, line:4:43> '<dependent type>' '<<' | | | |-UnresolvedLookupExpr 0x7f20ab97df48 <col:40> '<overloaded function type>' lvalue (ADL) = 'operator<<' 0x3b1a850 0x4bfc088 0x4bfbab0 0x3b18040 0x3b182b0 0x3b18520 0x3b18790 0x3b18a00 0x3b18c70 0x3b18ee0 0x3b19150 0x3b193c0 0x3b19630 0x3b198a0 0x3b19b10 0x3b19d80 0x3b19ff0 0x3b1a290 0x3b1da80 0x3b1ff00 0x3b26dc8 0x3b27af8 0x3b47870 0x3b47b80 0x3b51378 0x3b522d8 0x3b53468 0x3b54688 0x3b55818 0x3b569a8 0x3b58870 0x4e8b548 0x4e8e358 0x35c5ef0 0x35c63f8 0x3e7c2b0 0x3e99cb0 0x42b2f10 0x434e690 0x439da28 0x439e068 0x439e6a8 0x439ece0 0x439f288 0x439f838 0x43a6560 0x43a04f0 0x43a0a98 0x43a1078 0x43a5230 0x43e5858 0x44dd020 0x44eff88 0x45899e8 0x45e2068 0x45e6af8 0x45e7a48 0x45e8e78 0x45e9e28 0x45ead78 0x45ecb18 0x45edae8 0x46bbbc8 0x46ecb88 0x46c7d78 0x46c8c70 0x46c9b70 0x46cc0c0 0x47149c0 0x46cc7a0 0x472a210 0x46cd6a0 0x46ce5a0 0x46cf4a0 0x46d6080 0x46f7598 0x46f9b50 0x46fc158 0x470b2c0 0x470de40 0x47114d0 0x471e330 0x4720df0 0x4724f60 0x4727850 0x4737240 0x473be00 0x47408f0 0x4a996c8 0x48a6220 0x48a6dc0 0x48a7780 0x48a8140 0x48a8b60 0x49466b8 0x4947058 0x49479c8 | | | |-CXXOperatorCallExpr 0x7f20ab97ded0 <line:3:1, line:4:14> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | |-ImplicitCastExpr 0x7f20ab97deb8 <col:11> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | `-DeclRefExpr 0x7f20ab97de98 <col:11> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | |-CXXOperatorCallExpr 0x7f20ab97c4c0 <line:3:1, col:42> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | |-ImplicitCastExpr 0x7f20ab97c4a8 <col:39> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | `-DeclRefExpr 0x7f20ab97c488 <col:39> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | | |-CXXOperatorCallExpr 0x7f20ab97aad8 <col:1, col:36> 'std::ostream':'std::basic_ostream<char>' lvalue '<<' adl | | | | | | |-ImplicitCastExpr 0x7f20ab97aac0 <col:33> 'std::ostream &(*)(std::ostream &, const RVec<double> &)' <FunctionToPointerDecay> | | | | | | | `-DeclRefExpr 0x7f20ab97aaa0 <col:33> 'std::ostream &(std::ostream &, const RVec<double> &)' lvalue Function 0x7f20a829b218 'operator<<' 'std::ostream &(std::ostream &, const RVec<double> &)' | | | | | | |-CXXOperatorCallExpr 0x7f20ab9782e0 <col:1, col:14> 'basic_ostream<char, std::char_traits<char> >':'std::basic_ostream<char>' lvalue '<<' | | | | | | | |-ImplicitCastExpr 0x7f20ab9782c8 <col:11> 'basic_ostream<char, std::char_traits<char> > &(*)(basic_ostream<char, std::char_traits<char> > &, const char *)' <FunctionToPointerDecay> | | | | | | | | `-DeclRefExpr 0x7f20ab9782a8 <col:11> 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' lvalue Function 0x7f20a828f7e0 'operator<<' 'basic_ostream<char, std::char_traits<char> > &(basic_ostream<char, std::char_traits<char> > &, const char *)' | | | | | | | |-DeclRefExpr 0x7f20ab976920 <col:1, col:6> 'std::ostream':'std::basic_ostream<char>' lvalue Var 0x45f3bb0 'cout' 'std::ostream':'std::basic_ostream<char>' | | | | | | | `-ImplicitCastExpr 0x7f20ab978290 <col:14> 'const char *' <ArrayToPointerDecay> | | | | | | | `-StringLiteral 0x7f20ab976950 <col:14> 'const char [17]' lvalue "Sort the vector " | | | | | | `-ImplicitCastExpr 0x7f20ab97aa88 <col:36> 'const RVec<double>':'const ROOT::VecOps::RVec<double>' lvalue <NoOp> | | | | | | `-DeclRefExpr 0x7f20ab978318 <col:36> 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' lvalue Var 0xb4e03a0 'v1' 'ROOT::RVecD':'ROOT::VecOps::RVec<double>' | | | | | `-ImplicitCastExpr 0x7f20ab97c470 <col:42> 'const char *' <ArrayToPointerDecay> | | | | | `-StringLiteral 0x7f20ab97ab10 <col:42> 'const char [34]' lvalue ", take the two last elements and " | | | | `-ImplicitCastExpr 0x7f20ab97de80 <line:4:14> 'const char *' <ArrayToPointerDecay> | | | | `-StringLiteral 0x7f20ab97c538 <col:14> 'const char [24]' lvalue "reverse the selection: " | | | `-DeclRefExpr 0x7f20ab97df08 <col:43> 'auto' lvalue Var 0x7f20ab9761a8 'v9' 'auto' | | `-UnresolvedLookupExpr 0x7f20ab97e2e8 <col:49, col:54> '<overloaded function type>' lvalue (no ADL) = 'endl' 0x43a1658 | `-NullStmt 0x7f20ab97e6b0 <line:5:1> |-AnnotateAttr 0x7f20ab976280 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f20ab976380 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f20ab976490 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f20ab976560 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" |-AnnotateAttr 0x7f20ab976670 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" `-AnnotateAttr 0x7f20ab976740 <<invalid sloc>> Implicit R"ATTRDUMP(__ResolveAtRuntime)ATTRDUMP" <<<NULL>>>