C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
common-types.h
Go to the documentation of this file.
1// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3/*
4 © 2022 Intel Corporation
5
6 This software and the related documents are Intel copyrighted materials, and
7 your use of them is governed by the express license under which they were
8 provided to you ("License"). Unless the License provides otherwise, you may
9 not use, modify, copy, publish, distribute, disclose or transmit this software
10 or the related documents without Intel's prior written permission.
11
12 This software and the related documents are provided as is, with no express or
13 implied warranties, other than those that are expressly stated in the License.
14*/
15
16#ifndef SIMICS_TYPE_COMMON_TYPES_H
17#define SIMICS_TYPE_COMMON_TYPES_H
18
19#include <fmt/fmt/format.h>
20
21#include <cstddef> // size_t
22#include <string_view>
23
25
26namespace simics {
27namespace detail {
28
31 public:
32 constexpr ConstSizeT(size_t value = 0) // NOLINT(runtime/explicit)
33 : value_(value) {}
34 constexpr operator size_t () const {return value_;}
35
36 private:
37 size_t value_;
38};
39
40} // namespace detail
41
44
46using Description = std::string_view;
47
50
53
56
60
63} // namespace simics
64
65// Define the hash specialization for ConstSizeT
66namespace std {
67template <>
68struct hash<simics::detail::ConstSizeT> {
69 size_t operator()(const simics::detail::ConstSizeT &obj) const {
70 return hash<size_t>{}(size_t{obj});
71 }
72};
73} // namespace std
74
75// Define the formatter specialization for ConstSizeT
76namespace fmt {
77template <>
78struct formatter<simics::detail::ConstSizeT> : formatter<size_t> {
79 template <typename FormatContext>
81 FormatContext& ctx) { // NOLINT(runtime/references)
82 return formatter<size_t>::format(static_cast<size_t>(val), ctx);
83 }
84};
85} // namespace fmt
86
87#endif
Literal type that extends size_t type.
Definition: common-types.h:30
constexpr ConstSizeT(size_t value=0)
Definition: common-types.h:32
Represents name of a bank/register/field.
Definition: hierarchical-object-name.h:44
Definition: common-types.h:76
Definition: after-bank.h:33
std::string_view Description
Type used to describe a resource.
Definition: common-types.h:46
Definition: common-types.h:66
auto format(const simics::detail::ConstSizeT &val, FormatContext &ctx)
Definition: common-types.h:80
size_t operator()(const simics::detail::ConstSizeT &obj) const
Definition: common-types.h:69