Skip to content

Commit c380d2d

Browse files
committed
Headers: Fix a number of compile errors on various compilers
1 parent 6f4f551 commit c380d2d

File tree

19 files changed

+199
-94
lines changed

19 files changed

+199
-94
lines changed

headers/cstdarg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,32 @@
1818

1919
namespace std {
2020

21+
#ifdef va_start
22+
typedef ::va_list va_list;
23+
#else
2124
struct va_list {}; // actually a typedef
25+
#endif
2226

2327
} // namespace std
2428

29+
#ifndef va_start
2530
template<class T>
2631
void va_start(std::va_list ap, T parm_n); // actually a macro
32+
#endif
2733

34+
#ifndef va_arg
2835
#define va_arg(x, T) T()
36+
#endif
37+
2938
#if CPPREFERENCE_STDVER>= 2011
39+
#ifndef va_copy
3040
void va_copy(std::va_list desc, std::va_list src); // actually a macro
3141
#endif
42+
#endif
43+
44+
#ifndef va_end
3245
void va_end(std::va_list ap); // actually a macro
46+
#endif
3347

3448

3549
#endif // CPPREFERENCE_CSTDARG_H

headers/cuchar

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@
2121
#include <cstddef> // for size_t
2222
#include <cwchar> // for mbstate_t
2323

24+
#ifndef __STDC_UTF_16__
2425
#define __STDC_UTF_16__
26+
#endif
27+
28+
#ifndef __STDC_UTF_16__
2529
#define __STDC_UTF_32__
30+
#endif
2631

2732
namespace std {
2833

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt>
2+
3+
This file is part of cppreference-doc
4+
5+
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
6+
Unported License. To view a copy of this license, visit
7+
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
8+
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
9+
10+
Permission is granted to copy, distribute and/or modify this document
11+
under the terms of the GNU Free Documentation License, Version 1.3 or
12+
any later version published by the Free Software Foundation; with no
13+
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
14+
*/
15+
16+
#ifndef CPPREFERENCE_DETAIL_CPPREFERENCE_UNSPECIFIED_H
17+
#define CPPREFERENCE_DETAIL_CPPREFERENCE_UNSPECIFIED_H
18+
19+
// this is non-standard header
20+
21+
namespace std {
22+
23+
#if CPPREFERENCE_STDVER >= 2011
24+
using CPPREFERENCE_UNSPECIFIED_TYPE = int;
25+
constexpr int CPPREFERENCE_UNSPECIFIED_TYPE_VALUE = 0;
26+
#else
27+
typedef int CPPREFERENCE_UNSPECIFIED_TYPE;
28+
static const int CPPREFERENCE_UNSPECIFIED_TYPE_VALUE = 0;
29+
#endif
30+
31+
} // namespace std
32+
33+
#endif // CPPREFERENCE_DETAIL_LOCALE_FWD_H

headers/functional

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ public:
3939
function(std::nullptr_t);
4040
function(const function& other);
4141
function(function&& other);
42+
4243
template<class F >
43-
function(F f);
44+
function(F f) { (void) f; }
4445

4546
#if CPPREFERENCE_STDVER < 2017
4647
template<class Alloc >
@@ -125,7 +126,7 @@ std::function<R> bind(F&& f, Args&& ... args);
125126

126127
#if CPPREFERENCE_STDVER >= 2017
127128
template<class F, class... ArgTypes>
128-
std::result_of_t < F&& (ArgTypes&& ...) > invoke(F&& f, ArgTypes&& ... args);
129+
std::result_of_t<F&&(ArgTypes&&...)> invoke(F&& f, ArgTypes&&... args);
129130
#endif
130131

131132
// SIMPLIFIED: the inherited type is simplified

headers/future

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,20 @@ public:
187187
#if CPPREFERENCE_STDVER >= 2020
188188
template<class Function, class... Args>
189189
[[nodiscard]]
190-
std::future<typename std::invoke_result_of<Function, Args...>::type>
190+
std::future<typename std::invoke_result_t<Function, Args...>>
191191
async(Function&& f, Args&& ... args);
192192

193193
template<class Function, class... Args>
194194
[[nodiscard]]
195-
std::future<typename std::invoke_result_of<Function, Args...>::type>
195+
std::future<typename std::invoke_result_t<Function, Args...>>
196196
async(std::launch policy, Function&& f, Args&& ... args);
197197
#elif CPPREFERENCE_STDVER >= 2017
198198
template<class Function, class... Args>
199-
std::future<typename std::invoke_result_of<Function, Args...>::type>
199+
std::future<typename std::invoke_result_t<Function, Args...>>
200200
async(Function&& f, Args&& ... args);
201201

202202
template<class Function, class... Args>
203-
std::future<typename std::invoke_result_of<Function, Args...>::type>
203+
std::future<typename std::invoke_result_t<Function, Args...>>
204204
async(std::launch policy, Function&& f, Args&& ... args);
205205
#else
206206
template<class Function, class... Args>

headers/iosfwd

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@
1616
#ifndef CPPREFERENCE_IOSFWD_H
1717
#define CPPREFERENCE_IOSFWD_H
1818

19+
#include <cwchar> // for mbstate_t
20+
1921
namespace std {
2022

2123
template<class CharT> struct char_traits;
2224

2325
template<class T> class allocator;
2426

27+
typedef int streamoff;
28+
2529
class ios_base;
2630
template<class CharT, class Traits = std::char_traits<CharT>> class basic_ios;
2731

@@ -80,9 +84,10 @@ typedef basic_istringstream<wchar_t> wistringstream;
8084
typedef basic_ostringstream<wchar_t> wostringstream;
8185
typedef basic_stringstream<wchar_t> wstringstream;
8286

83-
template<class state> class fpos;
84-
typedef fpos<typename char_traits<char>::state_type> streampos;
85-
typedef fpos<typename char_traits<wchar_t>::state_type> wstreampos;
87+
template<class State> class fpos;
88+
// state type in below typedefs is actually impl-defined type char_traits<State>::state_type
89+
typedef fpos<mbstate_t> streampos;
90+
typedef fpos<mbstate_t> wstreampos;
8691

8792
} // namespace std
8893

headers/iterator

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#define CPPREFERENCE_ITERATOR_H
1818

1919
#include <cstddef> // for size_t, ptrdiff_t
20+
#include <iosfwd> // char_traits
21+
#include <initializer_list>
2022

2123
namespace std {
2224

@@ -146,11 +148,14 @@ class move_iterator {
146148
public:
147149
typedef Iterator iterator_type;
148150
typedef Iterator pointer;
149-
typedef value_type&& reference;
150151
#if CPPREFERENCE_SIMPLIFY_TYPEDEFS
152+
typedef typename Iterator::value_type value_type;
153+
typedef value_type&& reference;
151154
typedef typename ptrdiff_t difference_type;
152155
typedef typename Iterator::iterator_category iterator_category;
153156
#else
157+
typedef typename iterator_traits<Iterator>::value_type value_type;
158+
typedef value_type&& reference;
154159
typedef typename iterator_traits<Iterator>::difference_type difference_type;
155160
typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
156161
#endif
@@ -299,7 +304,7 @@ public:
299304
insert_iterator& operator++(int);
300305
protected:
301306
Container* container;
302-
Container::iterator iter;
307+
typename Container::iterator iter;
303308
};
304309

305310
template<class T,
@@ -331,11 +336,11 @@ public:
331336
istream_iterator operator++(int);
332337
};
333338

334-
template<class T, class CharT, class Traits, class Dist >
339+
template<class T, class CharT, class Traits, class Dist>
335340
bool operator==(const istream_iterator<T, CharT, Traits, Dist>& lhs,
336341
const istream_iterator<T, CharT, Traits, Dist>& rhs);
337342

338-
template<class CharT, class Traits >
343+
template<class T,class CharT, class Traits, class Dist>
339344
bool operator!=(const istream_iterator<T, CharT, Traits, Dist>& lhs,
340345
const istream_iterator<T, CharT, Traits, Dist>& rhs);
341346

@@ -369,12 +374,12 @@ template<class T, class CharT, class Traits >
369374
bool operator==(const ostream_iterator<T, CharT, Traits>& lhs,
370375
const ostream_iterator<T, CharT, Traits>& rhs);
371376

372-
template<class CharT, class Traits >
377+
template<class T, class CharT, class Traits>
373378
bool operator!=(const ostream_iterator<T, CharT, Traits>& lhs,
374379
const ostream_iterator<T, CharT, Traits>& rhs);
375380

376381

377-
template<class CharT, class Traits = std::char_traits<CharT> >
382+
template<class CharT, class Traits /*= std::char_traits<CharT>*/>
378383
class istreambuf_iterator { // SIMPLIFIED: does not inherit iterator
379384
public:
380385
typedef CharT char_type;
@@ -387,10 +392,10 @@ public:
387392
typedef std::basic_streambuf<CharT, Traits> streambuf_type;
388393
typedef std::basic_istream<CharT, Traits> istream_type;
389394

390-
typedef T value_type;
391-
typedef Distance difference_type;
392-
typedef const T* pointer;
393-
typedef const T& reference;
395+
typedef CharT value_type;
396+
typedef typename Traits::off_type difference_type;
397+
typedef const CharT* pointer; // actually unspecified
398+
typedef const CharT& reference;
394399
typedef input_iterator_tag iterator_category;
395400

396401
istreambuf_iterator();
@@ -417,7 +422,7 @@ bool operator!=(const istreambuf_iterator<CharT, Traits>& lhs,
417422
const istreambuf_iterator<CharT, Traits>& rhs);
418423

419424
template<class CharT,
420-
class Traits = std::char_traits<CharT> >
425+
class Traits /* = std::char_traits<CharT>*/ >
421426
class ostreambuf_iterator { // SIMPLIFIED: does not inherit iterator
422427
public:
423428
typedef CharT char_type;

headers/locale

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,16 @@ class wbuffer_convert : public std::basic_streambuf<Elem, Tr> {
123123
public:
124124
typedef typename Codecvt::state_type state_type;
125125

126+
#if CPPREFERENCE_STDVER >= 2011
127+
explicit wbuffer_convert(std::streambuf* bytebuf = nullptr,
128+
Codecvt* pcvt = new Codecvt,
129+
state_type state = state_type());
130+
#else
126131
explicit wbuffer_convert(std::streambuf* bytebuf = 0,
127132
Codecvt* pcvt = new Codecvt,
128133
state_type state = state_type());
134+
#endif
135+
129136
#if CPPREFERENCE_STDVER >= 2014
130137
wbuffer_convert(const wbuffer_convert&) = delete;
131138
#endif

headers/memory

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,12 @@ struct allocator {
443443
pointer address(reference x) const;
444444
const_pointer address(const_reference x) const;
445445

446+
#if CPPREFERENCE_STDVER >= 2011
447+
pointer allocate(size_type n, void* hint = nullptr);
448+
#else
446449
pointer allocate(size_type n, void* hint = 0);
450+
#endif
451+
447452
void deallocate(pointer p, size_type n);
448453
size_type max_size() const;
449454

headers/queue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <initializer_list>
2121
#endif
2222
#include <deque>
23+
#include <vector>
24+
#include <functional> // less
2325

2426
namespace std {
2527

0 commit comments

Comments
 (0)