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
23template <typename... Args>
24void beginAssembly(Args &&...args) {
25 // use the comma operator to transform a potentially void function call
26 // into a argument to allow proper parameter expansion for c++11
27 Impl::foreach_pack((args.beginAssembly(), 1)...);
28
29 // using c++17 the code would be
30 // (args.beginAssembly()...);
31}
32
33template <typename... Args>
34void endAssembly(Args &&...args) {
35 // use the comma operator to transform a potentially void function call
36 // into a argument to allow proper parameter expansion for c++11
37 Impl::foreach_pack((args.endAssembly(), 1)...);
38
39 // using c++17 the code would be
40 // (args.endAssembly()...);
41}
42
43template <typename... Args>
44void beginModify(Args &&...args) {
45 // use the comma operator to transform a potentially void function call
46 // into a argument to allow proper parameter expansion for c++11
47 Impl::foreach_pack((args.beginModify(), 1)...);
48
49 // using c++17 the code would be
50 // (args.beginModify()...);
51}
52
53template <typename... Args>
54void endModify(Args &&...args) {
55 // use the comma operator to transform a potentially void function call
56 // into a argument to allow proper parameter expansion for c++11
57 Impl::foreach_pack((args.endModify(), 1)...);
58
59 // using c++17 the code would be
60 // (args.endModify()...);
61}
62
63} // namespace Tpetra
64
65#endif // TPETRA_ASSEMBLY_HELPERS_HPP
Struct that holds views of the contents of a CrsMatrix.
Namespace Tpetra contains the class and methods constituting the Tpetra library.