timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
language.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2020, The Regents of the University of California,
4// through Lawrence Berkeley National Laboratory (subject to receipt of any
5// required approvals from the U.S. Dept. of Energy). All rights reserved.
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in all
15// copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23// SOFTWARE.
24
25#pragma once
26
27//======================================================================================//
28//
29// LANGUAGE
30//
31//======================================================================================//
32
33// Define C++20
34#if !defined(CXX20)
35# if __cplusplus > 201703L // C++20
36# define CXX20
37# endif
38#endif
39
40//--------------------------------------------------------------------------------------//
41
42// Define C++17
43#if !defined(CXX17)
44# if __cplusplus > 201402L // C++17
45# define CXX17
46# endif
47#endif
48
49//--------------------------------------------------------------------------------------//
50
51// Define C++14
52#if !defined(CXX14)
53# if __cplusplus > 201103L // C++14
54# define CXX14
55# endif
56#endif
57
58//--------------------------------------------------------------------------------------//
59
60#if !defined(CXX14)
61# if !defined(TIMEMORY_WINDOWS)
62# error "timemory requires __cplusplus > 201103L (C++14)"
63# endif
64#endif
65
66//--------------------------------------------------------------------------------------//
67
68#if !defined(IF_CONSTEXPR)
69# if defined(CXX17)
70# define IF_CONSTEXPR(...) if constexpr(__VA_ARGS__)
71# else
72# define IF_CONSTEXPR(...) if(__VA_ARGS__)
73# endif
74#endif
75
76//--------------------------------------------------------------------------------------//
77
78#if defined(CXX17)
79# include <string_view>
80//
81# if !defined(TIMEMORY_STRING_VIEW)
82# define TIMEMORY_STRING_VIEW 1
83# endif
84//
85namespace tim
86{
87using string_view_t = std::string_view;
88using string_view_cref_t = std::string_view;
89// string_views are trivially copyable so the instead of 'const string_view_t&' as a
90// function parameter, pass by value bc it enables more optimizations
91} // namespace tim
92//
93#else
94# include <string>
95//
96# if !defined(TIMEMORY_STRING_VIEW)
97# define TIMEMORY_STRING_VIEW 0
98# endif
99//
100namespace tim
101{
104// strings are not trivially copyable so, in C++14, we want to pass the string via
105// const ref
106} // namespace tim
107#endif
108
109//--------------------------------------------------------------------------------------//
Definition: kokkosp.cpp:39
std::string string_view_t
Definition: language.hpp:102
const std::string & string_view_cref_t
Definition: language.hpp:103
tim::mpl::apply< std::string > string
Definition: macros.hpp:53