Skip to content

Instantly share code, notes, and snippets.

@Axel-Naumann
Axel-Naumann / ROOT-llvm-upgrade-vs-v13.0.1.diff
Created June 22, 2022 14:38
Diff between llvmorg-13.0.1 vs llvm-upgrade branch of ROOT
--- /home/axel/build/llvm/src/clang/lib/Basic/SourceManager.cpp 2022-06-16 17:30:55.116188230 +0200
+++ /home/axel/build/root/llvmupgrade/src/interpreter/llvm/src/tools/clang/lib/Basic/SourceManager.cpp 2022-06-09 15:57:42.889506634 +0200
@@ -101,7 +101,7 @@
}
llvm::Optional<llvm::MemoryBufferRef>
-ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
+ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, const SourceManager &SM,
SourceLocation Loc) const {
// Lazily create the Buffer for ContentCaches that wrap files. If we already
@Axel-Naumann
Axel-Naumann / gist:b382330e724a4020625837c29843bb86
Created March 3, 2020 12:23
valgrind error in hsimple / RecursiveRemove
13:13 $ vg root.exe tutorials/hsimple.C
==22318== Memcheck, a memory error detector
==22318== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==22318== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==22318== Command: root.exe tutorials/hsimple.C
==22318==
------------------------------------------------------------------
| Welcome to ROOT 6.21/01 https://root.cern |
| (c) 1995-2019, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Feb 24 2020, 14:17:37 |
@Axel-Naumann
Axel-Naumann / v7color.cxx
Last active September 28, 2017 15:37
v7 attributes
using namespace ROOT::Experimental;
TCanvas canv;
// short for canv.GetFrame()->SetLogY():
canv.SetLogY();
// TPad background colors etc?!
THist1DDrawingOpts::Default().Box().LineWidth(3);
THist2DDrawingOpts::Default().SetLineWidth(7);
@Axel-Naumann
Axel-Naumann / treedraw_histprec.cxx
Created July 3, 2017 08:46
TTree::Draw() type change?
// This is the change:
tree->Draw("x");
// `hist` used to be a pointer to a `TH1F`, now is pointing to `TH1D`
auto hist = (TH1*)gDirectory->FindObject("htemp");
// QUESTION: Is that worse than people getting wrong results because of float precision?
// The change is not problematic when using it as `TH1`.
hist->Draw();
@Axel-Naumann
Axel-Naumann / namedparams.cxx
Last active May 9, 2017 09:57
Functions with named parameters
// Want to be able to call functions with naming parameters.
// Advantages:
// 1) readability: better than func(true, truie, false);
// 2) interface stability: can add parameters even in the middle
// 3) can skip default parameters in calls
// 4) enforces agreement on parameters' semantic meaning for all redecls
// 5) ...I'm missing something, what was it?
// Named parameters are introduced by a `!` preceding the parameter name
// (other options: `!` following the param name, but ambiguous with `!=`)
@Axel-Naumann
Axel-Naumann / exprlambda.cxx
Last active April 6, 2017 15:02
Short-hand lambda for single expressions
int capt = 42;
// Long lambda:
auto l0 = [&capt](auto&& x, auto&& y){ return x * y - capt; };
// Ideally want
auto l1 = [&capt]{ x * y - capt }; // NOT proposing this
// but that cannot be invoked by `l(12, 13);` - what is x, what is y?
// Instead this can work, with a new std::arg_v:
@Axel-Naumann
Axel-Naumann / aal.md
Last active April 6, 2017 13:10
Named params, auto-auto lambdas
void func(S s, bool is_yellow! = false, bool is_round!);
func(S{}, is_round = true);
int a = 12;
auto f = [!]{b*b + a*c}
auto r = f(b = 2, c = 7);
@Axel-Naumann
Axel-Naumann / indent.cxx
Created March 15, 2017 19:11
Indentation
void func (const vector<long double>& param);
std::stringstream& thisReturnsAStringStream(int i);
@Axel-Naumann
Axel-Naumann / indent.cxx
Created March 15, 2017 16:42
indent of members
auto df = GetDataFrameChecked();
const auto dBSize = defaultBranches.size();
const BranchNames_t &defaultBranches = df->GetDefaultBranches();
auto df = GetDataFrameChecked();
const BranchNames_t &defaultBranches = df->GetDefaultBranches();
const auto dBSize = defaultBranches.size();
@Axel-Naumann
Axel-Naumann / C# Expr Lambdas
Last active August 29, 2015 14:09
C++ vs C# Expr Lambdas
var allGood = myTree
.Select(t => particles.Where(p => p.fVector.Pt > minPt))
.Where(ps => ps.Count() >= N)
.SelectMany(ps => ps);