CMS 3D CMS Logo

transform.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_transform_h
2 #define FWCore_Utilities_transform_h
3 
4 #include <vector>
5 #include <type_traits>
6 
7 namespace edm {
8 
9  // helper template function to build a vector applying a transformation to the elements of an input vector
10  template <typename InputType, typename Function>
11  auto vector_transform(std::vector<InputType> const& input, Function predicate) -> std::vector<
12  typename std::remove_cv<typename std::remove_reference<decltype(predicate(input.front()))>::type>::type> {
13  using ReturnType =
14  typename std::remove_cv<typename std::remove_reference<decltype(predicate(input.front()))>::type>::type;
15  std::vector<ReturnType> output;
16  output.reserve(input.size());
17  for (auto const& element : input)
18  output.push_back(predicate(element));
19  return output;
20  }
21 
22 } // namespace edm
23 
24 #endif // FWCore_Utilities_transform_h
input
static const std::string input
Definition: EdmProvDump.cc:48
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm
HLT enums.
Definition: AlignableModifier.h:19
ecaldqm::ReturnType
std::map< DetId, double > ReturnType
Definition: DBReaderWorkers.cc:54
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
reco::parser::Function
Function
Definition: Function.h:18