1 //===-- StreamWrapper.cpp -------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "StreamWrapper.h"
16 namespace __llvm_libc
{
19 StreamWrapper
outs() { return {std::addressof(std::cout
)}; }
21 template <typename T
> StreamWrapper
&StreamWrapper::operator<<(T t
) {
23 std::ostream
&Stream
= *reinterpret_cast<std::ostream
*>(os
);
29 template StreamWrapper
&StreamWrapper::operator<<<void *>(void *t
);
30 template StreamWrapper
&StreamWrapper::operator<<<const char *>(const char *t
);
31 template StreamWrapper
&StreamWrapper::operator<<<char *>(char *t
);
32 template StreamWrapper
&StreamWrapper::operator<<<char>(char t
);
33 template StreamWrapper
&StreamWrapper::operator<<<short>(short t
);
34 template StreamWrapper
&StreamWrapper::operator<<<int>(int t
);
35 template StreamWrapper
&StreamWrapper::operator<<<long>(long t
);
36 template StreamWrapper
&StreamWrapper::operator<<<long long>(long long t
);
37 template StreamWrapper
&
38 StreamWrapper::operator<<<unsigned char>(unsigned char t
);
39 template StreamWrapper
&
40 StreamWrapper::operator<<<unsigned short>(unsigned short t
);
41 template StreamWrapper
&StreamWrapper::operator<<<unsigned int>(unsigned int t
);
42 template StreamWrapper
&
43 StreamWrapper::operator<<<unsigned long>(unsigned long t
);
44 template StreamWrapper
&
45 StreamWrapper::operator<<<unsigned long long>(unsigned long long t
);
46 template StreamWrapper
&StreamWrapper::operator<<<bool>(bool t
);
47 template StreamWrapper
&StreamWrapper::operator<<<std::string
>(std::string t
);
48 template StreamWrapper
&StreamWrapper::operator<<<float>(float t
);
49 template StreamWrapper
&StreamWrapper::operator<<<double>(double t
);
51 OutputFileStream::OutputFileStream(const char *FN
)
52 : StreamWrapper(new std::ofstream(FN
)) {}
54 OutputFileStream::~OutputFileStream() {
55 delete reinterpret_cast<std::ofstream
*>(os
);
58 } // namespace testutils
59 } // namespace __llvm_libc