Dune Core Modules (2.9.0)

misc.hh
Go to the documentation of this file.
1#ifndef DUNE_SPGRID_MISC_HH
2#define DUNE_SPGRID_MISC_HH
3
4#include <utility>
5#include <vector>
6
12namespace Dune
13{
14
22 template< class T, class Op >
23 inline std::vector< decltype( std::declval< Op >()( std::declval< T >() ) ) >
24 transform ( const std::vector< T > &in, Op op )
25 {
26 const std::size_t size = in.size();
27 std::vector< T > out;
28 out.reserve( size );
29 for( const T &v : in )
30 out.push_back( op( v ) );
31 return out;
32 }
33
34} // namespace Dune
35
36#endif // #ifndef DUNE_SPGRID_MISC_HH
Dune namespace.
Definition: alignedallocator.hh:13
std::vector< decltype(std::declval< Op >()(std::declval< T >())) > transform(const std::vector< T > &in, Op op)
copy a vector, performing an operation on each element
Definition: misc.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)