Skip to content

Commit c8f1863

Browse files
Alisdair Meredithzygoloid
authored andcommitted
[18-30] Replace typedefs with alias-declarations (#704)
This set of changes replace (almost) all use of 'typedef' in the library with a type alias instead: typedef Original NewName; -> using NewName = Original; Attention was paid to retaining table-like formatting where present, which is worth reviewing in case I made idiosyncratic choices. Clause 29 [atomic] was specifically ignored, as there is a desire for the contained code to look as close to a C compatible header as possible.
1 parent 2a5d972 commit c8f1863

File tree

11 files changed

+1090
-1086
lines changed

11 files changed

+1090
-1086
lines changed

source/containers.tex

Lines changed: 212 additions & 211 deletions
Large diffs are not rendered by default.

source/future.tex

Lines changed: 87 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@
155155
virtual streambuf* setbuf(char* s, streamsize n);
156156

157157
private:
158-
typedef T1 strstate; // \expos
159-
static const strstate allocated; // \expos
158+
using strstate = T1; // \expos
159+
static const strstate allocated; // \expos
160160
static const strstate constant; // \expos
161161
static const strstate dynamic; // \expos
162162
static const strstate frozen; // \expos
@@ -996,10 +996,10 @@
996996
: public basic_iostream<char> {
997997
public:
998998
// Types
999-
typedef char char_type;
1000-
typedef typename char_traits<char>::int_type int_type;
1001-
typedef typename char_traits<char>::pos_type pos_type;
1002-
typedef typename char_traits<char>::off_type off_type;
999+
using char_type = char;
1000+
using int_type = char_traits<char>::int_type;
1001+
using pos_type = char_traits<char>::pos_type;
1002+
using off_type = char_traits<char>::off_type;
10031003

10041004
// constructors/destructor
10051005
strstream();
@@ -1150,7 +1150,7 @@
11501150

11511151
\indexlibrary{\idxcode{unexpected_handler}}%
11521152
\begin{itemdecl}
1153-
typedef void (*unexpected_handler)();
1153+
using unexpected_handler = void (*)();
11541154
\end{itemdecl}
11551155

11561156
\begin{itemdescr}
@@ -1271,7 +1271,7 @@
12711271
To enable old function adaptors to manipulate function objects
12721272
that take one or two arguments,
12731273
many of the function objects in this standard
1274-
correspondingly provide typedefs
1274+
correspondingly provide \grammarterm{typedef-name}{s}
12751275
\tcode{argument_type} and \tcode{result_type}
12761276
for function objects that take one argument and
12771277
\tcode{first_argument_type}, \tcode{second_argument_type}, and \tcode{result_type}
@@ -1287,147 +1287,147 @@
12871287
\begin{codeblock}
12881288
namespace std {
12891289
template<class T> struct owner_less<shared_ptr<T> > {
1290-
typedef bool result_type;
1291-
typedef shared_ptr<T> first_argument_type;
1292-
typedef shared_ptr<T> second_argument_type;
1290+
using result_type = bool;
1291+
using first_argument_type = shared_ptr<T>;
1292+
using second_argument_type = shared_ptr<T>;
12931293
};
12941294

12951295
template<class T> struct owner_less<weak_ptr<T> > {
1296-
typedef bool result_type;
1297-
typedef weak_ptr<T> first_argument_type;
1298-
typedef weak_ptr<T> second_argument_type;
1296+
using result_type = bool;
1297+
using first_argument_type = weak_ptr<T>;
1298+
using second_argument_type = weak_ptr<T>;
12991299
};
13001300

13011301
template <class T> class reference_wrapper {
13021302
public :
1303-
typedef @\seebelow@ result_type; // not always defined
1304-
typedef @\seebelow@ argument_type; // not always defined
1305-
typedef @\seebelow@ first_argument_type; // not always defined
1306-
typedef @\seebelow@ second_argument_type; // not always defined
1303+
using result_type = @\seebelow@; // not always defined
1304+
using argument_type = @\seebelow@; // not always defined
1305+
using first_argument_type = @\seebelow@; // not always defined
1306+
using second_argument_type = @\seebelow@; // not always defined
13071307
};
13081308

13091309
template <class T> struct plus {
1310-
typedef T first_argument_type;
1311-
typedef T second_argument_type;
1312-
typedef T result_type;
1310+
using first_argument_type = T;
1311+
using second_argument_type = T;
1312+
using result_type = T;
13131313
};
13141314

13151315
template <class T> struct minus {
1316-
typedef T first_argument_type;
1317-
typedef T second_argument_type;
1318-
typedef T result_type;
1316+
using first_argument_type = T;
1317+
using second_argument_type = T;
1318+
using result_type = T;
13191319
};
13201320

13211321
template <class T> struct multiplies {
1322-
typedef T first_argument_type;
1323-
typedef T second_argument_type;
1324-
typedef T result_type;
1322+
using first_argument_type = T;
1323+
using second_argument_type = T;
1324+
using result_type = T;
13251325
};
13261326

13271327
template <class T> struct divides {
1328-
typedef T first_argument_type;
1329-
typedef T second_argument_type;
1330-
typedef T result_type;
1328+
using first_argument_type = T;
1329+
using second_argument_type = T;
1330+
using result_type = T;
13311331
};
13321332

13331333
template <class T> struct modulus {
1334-
typedef T first_argument_type;
1335-
typedef T second_argument_type;
1336-
typedef T result_type;
1334+
using first_argument_type = T;
1335+
using second_argument_type = T;
1336+
using result_type = T;
13371337
};
13381338

13391339
template <class T> struct negate {
1340-
typedef T argument_type;
1341-
typedef T result_type;
1340+
using argument_type = T;
1341+
using result_type = T;
13421342
};
13431343

13441344
template <class T> struct equal_to {
1345-
typedef T first_argument_type;
1346-
typedef T second_argument_type;
1347-
typedef bool result_type;
1345+
using first_argument_type = T;
1346+
using second_argument_type = T;
1347+
using result_type = bool;
13481348
};
13491349

13501350
template <class T> struct not_equal_to {
1351-
typedef T first_argument_type;
1352-
typedef T second_argument_type;
1353-
typedef bool result_type;
1351+
using first_argument_type = T;
1352+
using second_argument_type = T;
1353+
using result_type = bool;
13541354
};
13551355

13561356
template <class T> struct greater {
1357-
typedef T first_argument_type;
1358-
typedef T second_argument_type;
1359-
typedef bool result_type;
1357+
using first_argument_type = T;
1358+
using second_argument_type = T;
1359+
using result_type = bool;
13601360
};
13611361

13621362
template <class T> struct less {
1363-
typedef T first_argument_type;
1364-
typedef T second_argument_type;
1365-
typedef bool result_type;
1363+
using first_argument_type = T;
1364+
using second_argument_type = T;
1365+
using result_type = bool;
13661366
};
13671367

13681368
template <class T> struct greater_equal {
1369-
typedef T first_argument_type;
1370-
typedef T second_argument_type;
1371-
typedef bool result_type;
1369+
using first_argument_type = T;
1370+
using second_argument_type = T;
1371+
using result_type = bool;
13721372
};
13731373

13741374
template <class T> struct less_equal {
1375-
typedef T first_argument_type;
1376-
typedef T second_argument_type;
1377-
typedef bool result_type;
1375+
using first_argument_type = T;
1376+
using second_argument_type = T;
1377+
using result_type = bool;
13781378
};
13791379

13801380
template <class T> struct logical_and {
1381-
typedef T first_argument_type;
1382-
typedef T second_argument_type;
1383-
typedef bool result_type;
1381+
using first_argument_type = T;
1382+
using second_argument_type = T;
1383+
using result_type = bool;
13841384
};
13851385

13861386
template <class T> struct logical_or {
1387-
typedef T first_argument_type;
1388-
typedef T second_argument_type;
1389-
typedef bool result_type;
1387+
using first_argument_type = T;
1388+
using second_argument_type = T;
1389+
using result_type = bool;
13901390
};
13911391

13921392
template <class T> struct logical_not {
1393-
typedef T argument_type;
1394-
typedef bool result_type;
1393+
using argument_type = T;
1394+
using result_type = bool;
13951395
};
13961396

13971397
template <class T> struct bit_and {
1398-
typedef T first_argument_type;
1399-
typedef T second_argument_type;
1400-
typedef T result_type;
1398+
using first_argument_type = T;
1399+
using second_argument_type = T;
1400+
using result_type = T;
14011401
};
14021402

14031403
template <class T> struct bit_or {
1404-
typedef T first_argument_type;
1405-
typedef T second_argument_type;
1406-
typedef T result_type;
1404+
using first_argument_type = T;
1405+
using second_argument_type = T;
1406+
using result_type = T;
14071407
};
14081408

14091409
template <class T> struct bit_xor {
1410-
typedef T first_argument_type;
1411-
typedef T second_argument_type;
1412-
typedef T result_type;
1410+
using first_argument_type = T;
1411+
using second_argument_type = T;
1412+
using result_type = T;
14131413
};
14141414

14151415
template <class T> struct bit_not {
1416-
typedef T argument_type;
1417-
typedef T result_type;
1416+
using argument_type = T;
1417+
using result_type = T;
14181418
};
14191419

14201420
template<class R, class T1>
14211421
class function<R(T1)> {
14221422
public:
1423-
typedef T1 argument_type;
1423+
using argument_type = T1;
14241424
};
14251425

14261426
template<class R, class T1, class T2>
14271427
class function<R(T1, T2)> {
14281428
public:
1429-
typedef T1 first_argument_type;
1430-
typedef T2 second_argument_type;
1429+
using first_argument_type = T1;
1430+
using second_argument_type = T2;
14311431
};
14321432
}
14331433
\end{codeblock}
@@ -1525,17 +1525,17 @@
15251525
template <class Key, class T, class Compare, class Allocator>
15261526
class map<Key, T, Compare, Allocator>::value_compare {
15271527
public:
1528-
typedef bool result_type;
1529-
typedef value_type first_argument_type;
1530-
typedef value_type second_argument_type;
1528+
using result_type = bool;
1529+
using first_argument_type = value_type;
1530+
using second_argument_type = value_type;
15311531
};
15321532

15331533
template <class Key, class T, class Compare, class Allocator>
15341534
class multimap<Key, T, Compare, Allocator>::value_compare {
15351535
public:
1536-
typedef bool result_type;
1537-
typedef value_type first_argument_type;
1538-
typedef value_type second_argument_type;
1536+
using result_type = bool;
1537+
using first_argument_type = value_type;
1538+
using second_argument_type = value_type;
15391539
};
15401540
}
15411541
\end{codeblock}
@@ -1568,8 +1568,8 @@
15681568
public:
15691569
constexpr explicit unary_negate(const Predicate& pred);
15701570
constexpr bool operator()(const typename Predicate::argument_type& x) const;
1571-
typedef typename Predicate::argument_type argument_type;
1572-
typedef bool result_type;
1571+
using argument_type = typename Predicate::argument_type;
1572+
using result_type = bool;
15731573
};
15741574
\end{codeblock}
15751575

@@ -1600,9 +1600,10 @@
16001600
constexpr explicit binary_negate(const Predicate& pred);
16011601
constexpr bool operator()(const typename Predicate::first_argument_type& x,
16021602
const typename Predicate::second_argument_type& y) const;
1603-
typedef typename Predicate::first_argument_type first_argument_type;
1604-
typedef typename Predicate::second_argument_type second_argument_type;
1605-
typedef bool result_type;
1603+
using first_argument_type = typename Predicate::first_argument_type;
1604+
using second_argument_type = typename Predicate::second_argument_type;
1605+
using result_type = bool;
1606+
16061607
};
16071608
\end{codeblock}
16081609

0 commit comments

Comments
 (0)