aboutsummaryrefslogtreecommitdiff
path: root/std-core.mxx
blob: 27f9f1e35ad6c2b89aec1f8429ebd530309d5051 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// file      : std-core.mxx -*- C++ -*-
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

// For some standard library implementations we need to pre-include certain
// headers to prevent their exporting. And to detect a standard library we
// need to include a certain header first.
//
#if defined(__clang__)
#  if   __has_include(<__config>)         // libc++    _LIBCPP_VERSION
#    include <__config>
#  elif __has_include(<bits/c++config.h>) // libstdc++ __GLIBCXX__
#    include <bits/c++config.h>
#  endif
#elif defined(__GNUC__)
#  include <bits/c++config.h>             // libstdc++ __GLIBCXX__
#endif

#if   defined(_MSC_VER)
#elif defined(__GLIBCXX__)
#  include <ext/atomicity.h>   // Names with internal linkage.
#elif defined(_LIBCPP_VERSION)
#else
#  error unknown standard library implementation
#endif

export module std.core;

export
{
#include <cstddef>

  // These are defined in <bits/c++config.h> which we have pre-included.
  //
#ifdef __GLIBCXX__
  namespace std
  {
    typedef std::size_t size_t;
    typedef std::ptrdiff_t ptrdiff_t;
    typedef std::nullptr_t nullptr_t;
  }
#endif

#include <cstdint>
#include <cstdlib>

#include <utility>
#include <type_traits>

#include <exception>
#include <stdexcept>
}

export
{
#include <iterator>
#include <algorithm>

#include <string>
#include <cstring> // @@ Not in the proposal.

#include <array>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
}

#if defined(_MSC_VER) || defined(__clang__)
export
{
#include <cctype>
#include <iosfwd>
#include <istream>
#include <ostream>
#include <sstream>
#include <fstream>

#ifndef __GLIBCXX__
#  include <iostream>
#else
// Contents of <iostream> without static __ioinit.
//
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
  extern istream cin;
  extern ostream cout;
  extern ostream cerr;
  extern ostream clog;

  //static ios_base::Init __ioinit;
_GLIBCXX_END_NAMESPACE_VERSION
}
#endif
}


#endif