utility.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2013 Virginia Tech
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Justus Calvin
19  * Department of Chemistry, Virginia Tech
20  *
21  * utility.h
22  * Oct 18, 2013
23  *
24  */
25 
26 #ifndef TILEDARRAY_UTILITY_H__INCLUDED
27 #define TILEDARRAY_UTILITY_H__INCLUDED
28 
29 #include <array>
30 #include <atomic>
31 #include <initializer_list>
32 #include <iosfwd>
33 #include <iterator>
34 #include <vector>
35 
36 #include <TiledArray/type_traits.h>
37 
38 namespace TiledArray {
39 namespace detail {
40 
42 
47 template <typename A>
48 inline void print_array(std::ostream& out, const A& a, const std::size_t n) {
49  out << "[";
50  for (std::size_t i = 0; i < n; ++i) {
51  out << a[i];
52  if (i != (n - 1)) out << ",";
53  }
54  out << "]";
55 }
56 
58 
62 template <typename A>
63 inline void print_array(std::ostream& out, const A& a) {
64  using std::size;
65  print_array(out, a, size(a));
66 }
67 
68 inline std::atomic<bool>& ignore_tile_position_accessor() {
69  static std::atomic<bool> val{false};
70  return val;
71 }
72 } // namespace detail
73 
81 inline void ignore_tile_position(bool b) {
83 }
84 
90 inline bool ignore_tile_position() {
92 }
93 
94 } // namespace TiledArray
95 
96 #endif // TILEDARRAY_UTILITY_H__INCLUDED
void ignore_tile_position(bool b)
Definition: utility.h:81
void print_array(std::ostream &out, const A &a, const std::size_t n)
Print the content of an array like object.
Definition: utility.h:48
std::atomic< bool > & ignore_tile_position_accessor()
Definition: utility.h:68