Logo ROOT   6.14/05
Reference Guide
THistUtils.hxx
Go to the documentation of this file.
1 /// \file ROOT/THistData.h
2 /// \ingroup Hist ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2016-06-01
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
6 
7 /*************************************************************************
8  * Copyright (C) 1995-2016, Rene Brun and Fons Rademakers. *
9  * All rights reserved. *
10  * *
11  * For the licensing terms see $ROOTSYS/LICENSE. *
12  * For the list of contributors see $ROOTSYS/README/CREDITS. *
13  *************************************************************************/
14 
15 #ifndef ROOT7_THistUtils_h
16 #define ROOT7_THistUtils_h
17 
18 #include <array>
19 #include <type_traits>
20 
21 namespace ROOT {
22 namespace Experimental {
23 namespace Hist {
24 
25 template <int DIMENSIONS>
26 struct TCoordArray: std::array<double, DIMENSIONS> {
27  using Base_t = std::array<double, DIMENSIONS>;
28 
29  /// Default construction.
30  TCoordArray() = default;
31 
32  /// Construction with one `double` per `DIMENSION`.
33  template<class...ELEMENTS, class = typename std::enable_if<sizeof...(ELEMENTS) + 1 == DIMENSIONS>::type>
34  TCoordArray(double x, ELEMENTS...el): Base_t{{x, el...}} {}
35 
36  /// Fallback constructor, invoked if the one above fails because of the wrong number of
37  /// arguments / coordinates.
38  template<class T, class...ELEMENTS, class = typename std::enable_if<sizeof...(ELEMENTS) + 1 != DIMENSIONS>::type>
39  TCoordArray(T, ELEMENTS...) {
40  static_assert(sizeof...(ELEMENTS) + 1 == DIMENSIONS, "Number of coordinates does not match DIMENSIONS");
41  }
42 
43  /// Construction from a C-style array.
44  TCoordArray(double (&arr)[DIMENSIONS]): Base_t(arr) {}
45 };
46 
47 template <int DIMENSIONS>
48 //using CoordArray_t = std::array<double, DIMENSIONS>;
50 
51 
52 } // namespace Hist
53 } // namespace Experimental
54 } // namespace ROOT
55 
56 #endif //ROOT7_THistUtils_h
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
double T(double x)
Definition: ChebyshevPol.h:34
TCoordArray(double x, ELEMENTS...el)
Construction with one double per DIMENSION.
Definition: THistUtils.hxx:34
TCoordArray(T, ELEMENTS...)
Fallback constructor, invoked if the one above fails because of the wrong number of arguments / coord...
Definition: THistUtils.hxx:39
Double_t x[n]
Definition: legend1.C:17
std::array< double, DIMENSIONS > Base_t
Definition: THistUtils.hxx:27
int type
Definition: TGX11.cxx:120
TCoordArray(double(&arr)[DIMENSIONS])
Construction from a C-style array.
Definition: THistUtils.hxx:44
TCoordArray()=default
Default construction.