Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Assembly_Helpers.hpp
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TPETRA_ASSEMBLY_HELPERS_HPP
11#define TPETRA_ASSEMBLY_HELPERS_HPP
12
13namespace Tpetra {
14
15namespace Impl {
16// Helper function to to apply an operation to each member of a
17// c++11 parameter pack since parameter expansion only happens
18// within functions, constructors, and initializer_lists
19template <typename... Args>
20inline void foreach_pack(Args &&... args) {}
21} // namespace Impl
22
23
24template <typename... Args>
25void beginAssembly(Args &&... args)
26{
27 // use the comma operator to transform a potentially void function call
28 // into a argument to allow proper parameter expansion for c++11
29 Impl::foreach_pack( (args.beginAssembly(),1)... );
30
31 // using c++17 the code would be
32 // (args.beginAssembly()...);
33}
34
35template <typename... Args>
36void endAssembly(Args &&... args)
37{
38 // use the comma operator to transform a potentially void function call
39 // into a argument to allow proper parameter expansion for c++11
40 Impl::foreach_pack( (args.endAssembly(),1)... );
41
42 // using c++17 the code would be
43 // (args.endAssembly()...);
44
45}
46
47template <typename... Args>
48void beginModify(Args &&... args)
49{
50 // use the comma operator to transform a potentially void function call
51 // into a argument to allow proper parameter expansion for c++11
52 Impl::foreach_pack( (args.beginModify(),1)... );
53
54 // using c++17 the code would be
55 // (args.beginModify()...);
56}
57
58template <typename... Args>
59void endModify(Args &&... args)
60{
61 // use the comma operator to transform a potentially void function call
62 // into a argument to allow proper parameter expansion for c++11
63 Impl::foreach_pack( (args.endModify(),1)... );
64
65 // using c++17 the code would be
66 // (args.endModify()...);
67
68}
69
70}// namespace Tpetra
71
72#endif // TPETRA_ASSEMBLY_HELPERS_HPP
Namespace for new Tpetra features that are not ready for public release, but are ready for evaluation...
Namespace Tpetra contains the class and methods constituting the Tpetra library.