• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- StreamWrapper.cpp -------------------------------------------------===//
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 //===----------------------------------------------------------------------===//
8 
9 #include "StreamWrapper.h"
10 #include <cassert>
11 #include <iostream>
12 #include <memory>
13 #include <string>
14 
15 namespace __llvm_libc {
16 namespace testutils {
17 
outs()18 StreamWrapper outs() { return {std::addressof(std::cout)}; }
19 
operator <<(T t)20 template <typename T> StreamWrapper &StreamWrapper::operator<<(T t) {
21   assert(OS);
22   std::ostream &Stream = *reinterpret_cast<std::ostream *>(OS);
23   Stream << t;
24   return *this;
25 }
26 
27 template StreamWrapper &StreamWrapper::operator<<<void *>(void *t);
28 template StreamWrapper &StreamWrapper::operator<<<const char *>(const char *t);
29 template StreamWrapper &StreamWrapper::operator<<<char *>(char *t);
30 template StreamWrapper &StreamWrapper::operator<<<char>(char t);
31 template StreamWrapper &StreamWrapper::operator<<<short>(short t);
32 template StreamWrapper &StreamWrapper::operator<<<int>(int t);
33 template StreamWrapper &StreamWrapper::operator<<<long>(long t);
34 template StreamWrapper &StreamWrapper::operator<<<long long>(long long t);
35 template StreamWrapper &
36     StreamWrapper::operator<<<unsigned char>(unsigned char t);
37 template StreamWrapper &
38     StreamWrapper::operator<<<unsigned short>(unsigned short t);
39 template StreamWrapper &StreamWrapper::operator<<<unsigned int>(unsigned int t);
40 template StreamWrapper &
41     StreamWrapper::operator<<<unsigned long>(unsigned long t);
42 template StreamWrapper &
43     StreamWrapper::operator<<<unsigned long long>(unsigned long long t);
44 template StreamWrapper &StreamWrapper::operator<<<bool>(bool t);
45 template StreamWrapper &StreamWrapper::operator<<<std::string>(std::string t);
46 
47 } // namespace testutils
48 } // namespace __llvm_libc
49