test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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<typename std::remove_cv<typename std::remove_reference<decltype(predicate(input.front()))>::type>::type>
12  {
13  using ReturnType = typename std::remove_cv<typename std::remove_reference<decltype(predicate(input.front()))>::type>::type;
14  std::vector<ReturnType> output;
15  output.reserve( input.size() );
16  for (auto const & element : input)
17  output.push_back(predicate(element));
18  return output;
19  }
20 
21 } // namespace edm
22 
23 #endif // FWCore_Utilities_transform_h
type
Definition: HCALResponse.h:21
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
static std::string const input
Definition: EdmProvDump.cc:44
std::map< DetId, double > ReturnType