repr 0.1
Reconstructable string representations and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
type.h
Go to the documentation of this file.
#pragma once
#include <cstddef>
#include <sstream>
#include <string>
#include <string_view>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include "ctti.h"
#include "rtti.h"
namespace librepr {
template <typename T>
namespace detail {
template <typename T>
struct TemplateInfo {
static std::string name() { return librepr::get_name_raw<T>(); }
constexpr static bool is_templated = false;
};
template <template <typename...> typename U, typename... Ts>
struct TemplateInfo<U<Ts...>> {
using type = U<Ts...>;
using arguments = TypeList<Ts...>;
constexpr static bool is_templated = true;
private:
template <std::size_t... Idx>
consteval static auto get_min_required(std::index_sequence<Idx...> seq) -> std::size_t {
if constexpr (requires {
typename U<typename arguments::template get<Idx>...>; // pack::rebox<arguments::head<Idx>, U>
}) {
if constexpr (sizeof...(Idx) == 0) {
return 0;
} else {
return get_min_required(std::make_index_sequence<seq.size() - 1>());
}
}
return seq.size() + 1;
}
constexpr static auto required_amount = get_min_required(std::make_index_sequence<sizeof...(Ts)>());
public:
using required = typename arguments::template head<required_amount>;
using defaulted = typename arguments::template tail<required_amount>;
static std::string name() {
auto marker = full.find('<');
if (marker == full.npos) {
return full;
}
return REPR_FORMAT("{}<{}>", std::string_view(full.data(), marker), format_template_arguments());
}
constexpr static auto argument_count = USING(REPR_DEFAULT_TEMPLATE_ARGUMENTS) ? sizeof...(Ts) : required_amount;
return []<std::size_t... Idx>(std::index_sequence<Idx...>) {
const char* sep = "";
return out.str();
}
};
} // namespace detail
template <typename T>
char const* get_mangled_name() {
#if USING(LIBREPR_COMPILER_MSVC)
return typeid(T).raw_name();
#else
return typeid(T).name();
#endif
}
template <typename T>
} // namespace librepr