CMS 3D CMS Logo

getFixedSizeArray.h
Go to the documentation of this file.
1 #ifndef FWCore_ParameterSet_getFixedSizeArray_h
2 #define FWCore_ParameterSet_getFixedSizeArray_h
3 
6 
7 #include <algorithm>
8 #include <array>
9 #include <cstddef>
10 #include <string>
11 #include <vector>
12 
13 namespace edm {
14 
15  template <class T, std::size_t N>
16  std::array<T, N> getFixedSizeArray(ParameterSet const& pset, std::string const& name) {
17  std::vector<T> vec = pset.getParameter<std::vector<T>>(name);
18  if (vec.size() != N) {
20  << "The parameter '" << name << "' should have " << N << " elements, but has " << vec.size()
21  << " elements in the configuration.\n";
22  }
23  std::array<T, N> a{};
24  std::copy_n(vec.begin(), N, a.begin());
25  return a;
26  }
27 } // namespace edm
28 #endif
T getParameter(std::string const &) const
std::array< T, N > getFixedSizeArray(ParameterSet const &pset, std::string const &name)
#define N
Definition: blowfish.cc:9
HLT enums.
double a
Definition: hdecay.h:121