[libc++][Android] Allow testing libc++ with clang-r536225 (#116149)
[llvm-project.git] / libc / src / __support / c_string.h
blob11f41320681af85cf4d1c1ecf5e50f67500899a5
1 //===-- Implementation of a struct to hold a string in menory -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC___SUPPORT_C_STRING_H
10 #define LLVM_LIBC_SRC___SUPPORT_C_STRING_H
12 #include "src/__support/CPP/string.h"
13 #include "src/__support/macros/attributes.h" // for LIBC_INLINE
14 #include "src/__support/macros/config.h"
16 namespace LIBC_NAMESPACE_DECL {
18 // The CString class is a companion to the cpp::string class. Its use case is as
19 // a return value for a function that in C would return a char* and a flag for
20 // if that char* needs to be freed.
21 class CString {
22 cpp::string str;
24 public:
25 // These constructors can be implemented iff required.
26 CString() = delete;
27 CString(const CString &) = delete;
28 CString(CString &&) = delete;
30 LIBC_INLINE CString(cpp::string in_str) : str(in_str) {}
32 LIBC_INLINE operator const char *() const { return str.c_str(); }
35 } // namespace LIBC_NAMESPACE_DECL
37 #endif // LLVM_LIBC_SRC___SUPPORT_C_STRING_H