This file is indexed.

/usr/include/madness/world/print.h is in libmadness-dev 0.10.1~gite4aa500e-10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
  This file is part of MADNESS.

  Copyright (C) 2007,2010 Oak Ridge National Laboratory

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

  For more information please contact:

  Robert J. Harrison
  Oak Ridge National Laboratory
  One Bethel Valley Road
  P.O. Box 2008, MS-6367

  email: harrisonrj@ornl.gov
  tel:   865-241-3937
  fax:   865-572-0680
*/

#ifndef MADNESS_WORLD_PRINT_H__INCLUDED
#define MADNESS_WORLD_PRINT_H__INCLUDED

/**
 \file print.h
 \brief Defines simple templates for printing to \c std::cout "a la Python".
 \ingroup libraries
*/

#include <type_traits>
#include <iostream>
#include <complex>
#include <list>
#include <vector>
#include <madness/world/worldmutex.h>

#ifdef BRAINDEAD
// Cray XT nonsense
#define ENDL "\n"

#else

#define ENDL std::endl

#endif


namespace madness {

    /// \addtogroup libraries
    /// @{

    /// Easy printing of complex numbers.

    /// \tparam T The "real" type of the complex number.
    /// \param[in,out] s The output stream.
    /// \param[in] c The complex number.
    /// \return The output stream (for chaining).
    template <typename T>
    std::ostream& operator<<(std::ostream& s, const std::complex<T>& c) {
        s << c.real() << "+" << c.imag() << "j";
        return s;
    }

    /// Easy printing of pairs.

    /// \tparam T Type 1 of the pair.
    /// \tparam U Type 2 of the pair.
    /// \param[in,out] s The output stream.
    /// \param[in] p The pair.
    /// \return The output stream (for chaining).
    template <typename T, typename U>
    std::ostream& operator<<(std::ostream& s, const std::pair<T,U>& p) {
        s << "(" << p.first << "," << p.second << ")";
        return s;
    }

    /// Easy printing of lists.

    /// \tparam T Type stored in the list.
    /// \param[in,out] s The output stream.
    /// \param[in] c The list.
    /// \return The output stream (for chaining).
    template <typename T>
    std::ostream& operator<<(std::ostream& s, const std::list<T>& c) {
        s << "[";
        typename std::list<T>::const_iterator it = c.begin();
        while (it != c.end()) {
            s << *it;
            ++it;
            if (it != c.end()) s << ", ";
        };
        s << "]";
        return s;
    }

    /// Easy printing of vectors.

    /// \tparam T Type stored in the vector.
    /// \param[in,out] s The output stream.
    /// \param[in] c The vector.
    /// \return The output stream (for chaining).
    template <typename T>
    std::ostream& operator<<(std::ostream& s, const std::vector<T>& c) {
        s << "[";
        typename std::vector<T>::const_iterator it = c.begin();
        while (it != c.end()) {
            s << *it;
            ++it;
            if (it != c.end()) s << ", ";
        };
        s << "]";
        return s;
    }

    /// Easy printing of fixed dimension arrays.

    /// STL I/O already does char (thus the \c enable_if business).
    /// \tparam T Type of data in the array.
    /// \tparam N Size of the array.
    /// \param[in,out] s The output stream.
    /// \param[in] v The array.
    /// \return The output stream (for chaining).
    template <typename T, std::size_t N>
    typename std::enable_if<!std::is_same<T,char>::value, std::ostream&>::type
    operator<<(std::ostream& s, const T(&v)[N]) {
        s << "[";
        for (std::size_t i=0; i<N; ++i) {
            s << v[i];
            if (i != (N-1)) s << ",";
        }
        s << "]";
        return s;
    }

    /// Print a string justified on the left to start at the given column with optional underlining.
    void print_justified(const char* s, int column=0, bool underline=true);

    /// Print a string centered at the given column with optional underlining.
    void print_centered(const char* s, int column=40, bool underline=true);


    // the "print" function and functions to help handle the variadic templates

    /// Helper function for \c print. Base case.

    /// This gets called recursively when there are no items left to print.
    /// \param[in,out] out Output stream.
    /// \return The output stream (for chaining).
    inline std::ostream& print_helper(std::ostream& out) {
        return out;
    }

    /// \brief Helper function for \c print. Prints the first item (\c t) and
    ///    recursively passes on the other items.

    /// \tparam T Type of the item to print in this call.
    /// \tparam Ts Argument pack type for the remaining items.
    /// \param[in,out] out Output stream.
    /// \param[in] t The item to print in this call.
    /// \param[in] ts The remaining items in the argument pack (they get
    ///    recursively passed on).
    /// \return The output stream (for chaining).
    template <typename T, typename... Ts>
    inline std::ostream& print_helper(std::ostream& out,
                                      const T& t, const Ts&... ts) {
        out << ' ' << t;
        return print_helper(out, ts...);
    }

    /// \brief Print items to \c std::cout (items separated by spaces) and
    ///    terminate with a new line

    /// The first item is printed here so that it isn't preceded by a space.
    /// \tparam T Type of the first item to be printed.
    /// \tparam Ts Argument pack type for the items to be printed.
    /// \param[in] t The first item to be printed.
    /// \param[in] ts The remaining items to be printed in the argument pack.
    template<typename T, typename... Ts>
    void print(const T& t, const Ts&... ts) {
        ScopedMutex<Mutex> safe(detail::printmutex);
        std::cout << t;
        print_helper(std::cout, ts...) << ENDL;
    }

    /// @}

}
#endif // MADNESS_WORLD_PRINT_H__INCLUDED