Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
13 namespace Tpetra {
14 
15 namespace 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
19 template <typename... Args>
20 inline void foreach_pack(Args &&... args) {}
21 } // namespace Impl
22 
23 
24 template <typename... Args>
25 void 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 
35 template <typename... Args>
36 void 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 
47 template <typename... Args>
48 void 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 
58 template <typename... Args>
59 void 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