/usr/include/xtensor/xinfo.hpp is in xtensor-dev 0.10.11-1.
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 | /***************************************************************************
* Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
#include <string>
namespace xt
{
// see http://stackoverflow.com/a/20170989
struct static_string
{
template <std::size_t N>
constexpr static_string(const char (&a)[N]) noexcept
: data(a), size(N - 1)
{
}
constexpr static_string(const char* a, const std::size_t sz) noexcept
: data(a), size(sz)
{
}
const char* const data;
const std::size_t size;
};
template <class T>
constexpr static_string type_name()
{
#ifdef __clang__
static_string p = __PRETTY_FUNCTION__;
return static_string(p.data + 31, p.size - 31 - 1);
#elif defined(__GNUC__)
static_string p = __PRETTY_FUNCTION__;
#if __cplusplus < 201402
return static_string(p.data + 36, p.size - 36 - 1);
#else
return static_string(p.data + 46, p.size - 46 - 1);
#endif
#elif defined(_MSC_VER)
static_string p = __FUNCSIG__;
return static_string(p.data + 38, p.size - 38 - 7);
#endif
}
template <class T>
constexpr std::string type_to_string()
{
static_string static_name = type_name<T>();
return std::string(static_name.data, static_name.size);
}
template <class T>
std::string info(const T& t)
{
std::string s;
using shape_type = typename T::shape_type;
if (detail::is_array<shape_type>::value)
{
s += "Type: xtensor, fixed dimension " + std::to_string(t.dimension());
}
else
{
s += "Type: xarray, dimension " + std::to_string(t.dimension());
}
s += "\nValue type: " + type_to_string<typename T::value_type>();
s += "\nLayout: ";
if (t.layout() == layout_type::row_major)
{
s += "row_major";
}
else if (t.layout() == layout_type::column_major)
{
s += "column_major";
}
else if (t.layout() == layout_type::dynamic)
{
s += "dynamic";
}
else
{
s += "any";
}
s += "\nShape: (";
bool first = true;
for (const auto& el : t.shape())
{
if (!first)
{
s += ", ";
}
first = false;
s += std::to_string(el);
}
s += ")\nStrides: (";
first = true;
for (const auto& el : t.strides())
{
if (!first)
{
s += ", ";
}
first = false;
s += std::to_string(el);
}
s += ")\nSize: " + std::to_string(t.size()) + "\n";
return s;
}
}
|