wx2017
October 29, 2022, 2:29pm
1
I compile ROOT from source by using the following settings:
cmake -Dbuiltin_afterimage=ON -Dxrootd=OFF -DCMAKE_INSTALL_PREFIX=../root_install -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_STANDARD=17 and -Droot7=ON ../root_src
The compilation is successful. But following command failed:
root [3] std::any a(12)
ROOT_prompt_3:1:6: error: no member named ‘any’ in namespace ‘std’
std::any is a c++17 feature. I was assuming ROOT will be able to handle this after enable c++17.
_ROOT Version: root.6.28.08
_Platform: unbuntu
_Compiler:gcc9.4
emphasized text
root [0] #include <any>
root [1] std::any a(12)
(std::any &) @0x7fba7b256010
1 Like
wx2017
October 30, 2022, 1:15am
3
Thanks. adding the command #include solve the problem.
How to use std::any in pyROOT? I tried the following:
import ROOT
a = ROOT.std.any()
Traceback (most recent call last):
File “”, line 1, in
AttributeError: <namespace cppyy.gbl.std at 0x558f5c6b83a0> has no attribute ‘any’. Full details:
type object ‘std’ has no attribute ‘any’
‘std::any’ is not a known C++ class
‘any’ is not a known C++ template
‘any’ is not a known C++ enum
Try: ROOT.gROOT.ProcessLine('#include <any>')
or: ROOT.gInterpreter.ProcessLine('#include <any>')
or (better?): ROOT.gInterpreter.Declare('#include <any>')
@Axel What is actually the best way to deal with it? Via “gROOT” or “gInterpreter”? Using “ProcessLine” or “ProcessLineSynch” or “Declare”?
1 Like
For header inclusion, Declare
is probably best as it has less side-effects and tries to perform less magic behind the scenes.
1 Like
wx2017
November 3, 2022, 10:25pm
6
Here is a follow up question on the format of std::vector or std::map in ROOT6.26.08 with c++17 turned on.
The following command doesn’t work:
>>> a = ROOT.std.vector[string]()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'string' is not defined
but the old way still works:
>>> a = ROOT.std.vector['string']()
Is this a bug or feature?
Not a bug, the Python interpreter correctly complains that it doesn’t know what string
means. It’s not a variable name nor a Python type.
ROOT.std.vector[ROOT.std.string]
should also work.
Cheers,
Enrico
1 Like
system
Closed
November 18, 2022, 8:02am
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.