Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
new/memory.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright © 2017 Franklin "Snaipe" Mathieu <http://snai.pe/>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#ifndef CRITERION_NEW_MEMORY_H_
25#define CRITERION_NEW_MEMORY_H_
26
27#include "../internal/common.h"
28
29struct cr_mem {
30 const void *data;
31 size_t size;
32
33#ifdef __cplusplus
34 template <typename T, size_t N>
35 constexpr cr_mem(const T (&arr)[N])
36 : data(static_cast<const void *>(&arr)), size(N)
37 {}
38
39 template <typename T>
40 constexpr cr_mem(const T *arr, size_t n)
41 : data(static_cast<const void *>(arr)), size(n)
42 {}
43#endif /* !__cplusplus */
44};
45
46#ifdef __cplusplus
47namespace criterion {
48 using memory = cr_mem;
49}
50
51inline bool operator==(const criterion::memory &m1, const criterion::memory &m2);
52inline bool operator<(const criterion::memory &m1, const criterion::memory &m2);
53inline std::ostream &operator<<(std::ostream &s, const criterion::memory &m);
54#endif /* !__cplusplus */
55
57
58CR_API int cr_user_mem_eq(const struct cr_mem *m1, const struct cr_mem *m2);
59CR_API int cr_user_mem_lt(const struct cr_mem *m1, const struct cr_mem *m2);
60CR_API char *cr_user_mem_tostr(const struct cr_mem *m);
61
63
65
66#endif /* !CRITERION_NEW_MEMORY_H_ */
#define CR_BEGIN_C_API
Definition common.h:54
#define CR_API
Definition common.h:128
#define CR_END_C_API
Definition common.h:55
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318
DOCTEST_INTERFACE bool operator==(const String &lhs, const String &rhs)
DOCTEST_INTERFACE bool operator<(const String &lhs, const String &rhs)
basic_ostream< char, traits > & operator<<(basic_ostream< char, traits > &, const char *)
CR_API int cr_user_mem_lt(const struct cr_mem *m1, const struct cr_mem *m2)
CR_BEGIN_C_API CR_API int cr_user_mem_eq(const struct cr_mem *m1, const struct cr_mem *m2)
CR_API char * cr_user_mem_tostr(const struct cr_mem *m)
size_t size
Definition new/memory.h:31
const void * data
Definition new/memory.h:30