Download ebooks file C++17 Standard Library Quick Reference, 2nd Edition: A Pocket Guide to Data Structures, Algorithms, and Functions Peter Van Weert all chapters
Download ebooks file C++17 Standard Library Quick Reference, 2nd Edition: A Pocket Guide to Data Structures, Algorithms, and Functions Peter Van Weert all chapters
com
https://ebookmeta.com/product/c17-standard-library-quick-
reference-2nd-edition-a-pocket-guide-to-data-structures-
algorithms-and-functions-peter-van-weert/
OR CLICK BUTTON
DOWNLOAD NOW
https://ebookmeta.com/product/c-10-quick-syntax-reference-a-pocket-
guide-to-the-language-apis-and-library-mikael-olsson/
ebookmeta.com
https://ebookmeta.com/product/c-8-quick-syntax-reference-3rd-edition-
a-pocket-guide-to-the-language-apis-and-library-mikael-olsson/
ebookmeta.com
https://ebookmeta.com/product/r-quick-syntax-reference-2nd-edition-a-
pocket-guide-to-the-language-apis-and-library-margot-tollefson/
ebookmeta.com
https://ebookmeta.com/product/the-toxicology-of-essential-and-
nonessential-metals-1st-edition-nichole-coleman/
ebookmeta.com
Client consultant model services agreement 5th Edition
International Federation Of Consulting Engineers.
https://ebookmeta.com/product/client-consultant-model-services-
agreement-5th-edition-international-federation-of-consulting-
engineers/
ebookmeta.com
https://ebookmeta.com/product/the-story-of-the-western-wing-shi-fu-
wang/
ebookmeta.com
https://ebookmeta.com/product/falling-from-grace-downward-mobility-in-
the-age-of-affluence-katherine-s-newman/
ebookmeta.com
https://ebookmeta.com/product/turnover-vegas-aces-the-quarterback-
book-4-1st-edition-lisa-suzanne/
ebookmeta.com
https://ebookmeta.com/product/pragmatics-a-resource-book-for-
students-4th-edition-joan-cutting-kenneth-fordyce/
ebookmeta.com
The Anti-Oligarchy Constitution : Reconstructing the
Economic Foundations of American Democracy 1st Edition
Joseph Fishkin
https://ebookmeta.com/product/the-anti-oligarchy-constitution-
reconstructing-the-economic-foundations-of-american-democracy-1st-
edition-joseph-fishkin/
ebookmeta.com
C++17 Standard
Library Quick
Reference
A Pocket Guide to Data Structures,
Algorithms, and Functions
—
Second Edition
—
Peter Van Weert
Marc Gregoire
www.allitebooks.com
C++17 Standard
Library Quick
Reference
A Pocket Guide to Data Structures,
Algorithms, and Functions
Second Edition
www.allitebooks.com
C++17 Standard Library Quick Reference: A Pocket Guide to Data
Structures, Algorithms, and Functions
Peter Van Weert Marc Gregoire
Kessel-Lo, Belgium Meldert, Belgium
ISBN-13 (pbk): 978-1-4842-4922-2 ISBN-13 (electronic): 978-1-4842-4923-9
https://doi.org/10.1007/978-1-4842-4923-9
www.allitebooks.com
Dedicated to my parents and my brother,
who are always there for me.
Their support and patience helped me
in finishing this book.
—Marc Gregoire
www.allitebooks.com
Contents
www.allitebooks.com
■ Contents
Beta Functions���������������������������������������������������������������������������������������������������������� 9
Zeta Functions���������������������������������������������������������������������������������������������������������� 9
Minimum, Maximum, and Clamping����������������������������������� <algorithm> 9
Fixed-Width Integer Types���������������������������������������������������� <cstdint> 10
Arithmetic Type Properties����������������������������������������������������� <limits> 11
Complex Numbers���������������������������������������������������������������� <complex> 13
Compile-Time Rational Numbers��������������������������������������������� <ratio> 14
Random Numbers������������������������������������������������������������������ <random> 15
Random Number Generators���������������������������������������������������������������������������������� 15
Random Number Distributions������������������������������������������������������������������������������� 18
vi
■ Contents
std::optional�������������������������������������������������������������������������������������� <optional> 48
std::variant������������������������������������������������������������������������������������������ <variant> 50
std::any��������������������������������������������������������������������������������������������������������<any> 55
Type Utilities����������������������������������������������������������������������������������������� 62
Runtime Type Identification������������������������������������� <typeinfo>, <typeindex> 62
Type Traits�����������������������������������������������������������������������������������<type_traits> 63
Type Operations���������������������������������������������������������������������������������� <utility> 70
Generic Utilities������������������������������������������������������������������������������������� 71
std::invoke C++17 ������������������������������������������������������������������������� <functional> 71
std::addressof��������������������������������������������������������������������������������������� <memory> 72
vii
■ Contents
std::bitset������������������������������������������������������������������������������� <bitset> 89
Complexity�������������������������������������������������������������������������������������������������������������� 90
Reference��������������������������������������������������������������������������������������������������������������� 90
Container Adaptors������������������������������������������������������������������������������� 91
std::queue����������������������������������������������������������������������������������������������� <queue> 91
std::priority_queue��������������������������������������������������������������������������������� <queue> 91
std::stack������������������������������������������������������������������������������������������������ <stack> 92
Example������������������������������������������������������������������������������������������������������������������ 92
Reference��������������������������������������������������������������������������������������������������������������� 93
viii
■ Contents
Complexity������������������������������������������������������������������������������������������������������������ 101
Reference������������������������������������������������������������������������������������������������������������� 101
Terminology���������������������������������������������������������������������������������������� 115
Algorithms���������������������������������������������������������������������� <algorithm> 115
Applying a Function to a Range���������������������������������������������������������������������������� 115
Checking for the Presence of Elements���������������������������������������������������������������� 117
Finding Elements�������������������������������������������������������������������������������������������������� 117
Finding Min/Max Elements����������������������������������������������������������������������������������� 118
Binary Search������������������������������������������������������������������������������������������������������� 119
Subsequence Search�������������������������������������������������������������������������������������������� 120
Sequence Comparison������������������������������������������������������������������������������������������ 121
Generating Sequences������������������������������������������������������������������������������������������ 122
Copy, Move, Swap������������������������������������������������������������������������������������������������� 123
Removing and Replacing�������������������������������������������������������������������������������������� 124
Reversing and Rotating���������������������������������������������������������������������������������������� 125
ix
■ Contents
Partitioning����������������������������������������������������������������������������������������������������������� 126
Sorting������������������������������������������������������������������������������������������������������������������ 127
Sampling and Shuffling���������������������������������������������������������������������������������������� 128
Operations on Sorted Ranges������������������������������������������������������������������������������� 129
Permutation���������������������������������������������������������������������������������������������������������� 130
Heaps�������������������������������������������������������������������������������������������������������������������� 131
x
■ Contents
xi
■ Contents
xii
■ Contents
xiii
■ Contents
std::terminate()����������������������������������������������������������������������������������������������������� 266
Index���������������������������������������������������������������������������������������������� 279
xiv
About the Authors
xv
Other documents randomly have
different content
"They belong as much to Mr. Vanderput as to us, you know. Is Mr.
Vanderput here to-day?"
"To be sure. He is to be at the burial-feast; and Miss Gertrude----."
"Gertrude! Is Gertrude here?" cried Christian, sitting up with a jerk
which alarmed his attendant for the consequences. "O, if she will
stay the whole day, it will be as good as the pastor having come
back."
"She crossed from Saardam on purpose. She will tell you about
the angels, if any body can; for she lives in heaven as much as the
pastor himself, they say."
"She is an angel herself," quietly observed Gertrude's little adorer.
Katrina went on with her list.
"Then there is Fransje Slyk and her father. He looks as if he knew
what a funeral should be, and as grave as if he had been own
brother to the departed. I cannot say as much for Fransje."
"I had rather have Fransje's behaviour than her father's, though I
do not much like her," said Christian. "Mr. Slyk always glances round
to see how other people are looking, before he settles his face
completely."
"Well; you will see how he looks to-day. These are all who will stay
till evening, I believe, except Mr. Visscher."
"Mr. Visscher! What is he to stay for? I suppose Heins wants to
talk to him about this new cargo that came too late. O, Kaatje, I
never can bear to look through the trees at that ship again. I saw the
white sails in the moonlight all that night when I lay watching what
was going on, and heard Heins's step in and out, and my mother's
voice when she thought nobody heard her; and I could not catch a
breath of my father's voice, though I listened till the rustle of my head
on the pillow startled me. And then my mother came in, looking so
that I thought my father was better; but she came to tell me that I
should never hear his voice any more. But O, if she knew how often I
have heard it since! how glad I should be to leave off hearing it when
I am alone----."
Poor Christian wept so as not to be comforted till his beloved
friend Gertrude came to hear what he had to say about those whom
he believed to be her kindred angels.
Heins was missed from the company soon after the less familiar
guests had departed, and left the intimate friends of the family to
complete the offices of condolence. Heins was as soon weary of
constraint as most people, which made it the more surprising that he
imposed on himself so much more of it than was necessary. All knew
pretty well what Heins was, though he was perpetually striving to
seem something else; and his painful efforts were just so much
labour in vain. Every body knew this morning, through all the
attempts to feel grief by which he tried to cheat himself and others,
that his father's death was quite as much a relief as a sorrow to him;
and that, while he wore a face of abstraction, he was longing for
some opportunity of getting out upon the quay to learn tidings of the
ships and cargoes of which he was now in fact master. The fact was
that Heins was as much bent on being rich as his father had been,
but he wanted to make greater haste to be so, and to enjoy free
scope for a trial of his more liberal commercial notions. For this free
scope, he must yet wait; for his partner, Mr. Vanderput, was as
steady a man of business, though a less prejudiced one, than the
senior Snoek had been; and then there was Mrs. Snoek. She was
not permitted, by the customs of the country, to meddle in affairs
relating to commerce; but she knew her maternal duty too well not to
keep an eye on the disposal of the capital which included the
fortunes of her younger children. It was to be apprehended that she
would be ready with objections whenever a particularly grand
enterprize should demand the union of all the resources of the firm.
Some liberty had, however, been gained through the obstinacy of the
fever which would not yield to French brandy and Oriental spices;
and there were many eyes upon Heins already, to watch how he
would set out on his commercial career.
Some of these eyes followed him from his mother's door to the
quay, and back again, when he had concluded his inquiries among
the captains. It was remarked that there was, during the latter transit,
a gloom in his countenance which was no mockery.
On his re-appearance in his mother's parlour, the cause was soon
told, first to his partner, next to his mother, and then (as there were
none but intimate friends) to all present. The result of the
communication was an outcry against the English, as very
troublesome neighbours, while the widow's first thought was of
thankfulness that her husband had died without hearing news which
would have caused him great trouble of mind. Heins appealed to all
who understood the state of Dutch commerce, whether Great Britain
had not done mischief enough long ago, by prohibiting the
importation of bulky goods by any ships but those which belonged to
the exporting or importing country.
"That prohibition was evidently aimed at us Dutch," observed
Vanderput. "We were carriers to half the world, till Great Britain
chose that we should no longer carry for her. She might punish
herself in that manner, and welcome, if she could do so without
punishing us; but it is a serious grievance,--difficult as it now is to
find an investment for our capital,--to be obliged to lay by any of our
shipping as useless."
"We did all we could," said Heins piteously. "Since we could not
carry the produce of the East and West into the ports of Great Britain
for sale, we brought it here, that the British captains might not have
far to go for it. But it seems that Great Britain is jealous of this; for
there is a new prohibition (if the report be true) against importing any
bulky produce purchased anywhere but in the country where it is
produced."
"I hope this is too bad to be true," observed Visscher.
"Nothing is too bad to be attempted by a jealous country against
one which has been particularly successful in commerce," observed
Snoek. "The tonnage of this country is more than half that of all
Europe; and Great Britain thinks it time to lower our superiority.
Whether she will gain by doing so, time will show."
"I think Great Britain is very illnatured and very mean," observed
Christian, who had generally something to say on every subject that
was discussed in his presence. "I think I shall call her Little Britain,
from this time. But, Heins, what will you do with all the things you
have bought, as you told me, in Asia and America, and in France
and Italy? You must send back your cinnamon to Ceylon, and----O,
but I forgot that other people may buy them, though the English will
not. But I hope you have not bought too much for the present
number of your customers. There is another large ship coming from
one of the American islands, I heard----."
He was checked by the remembrance of who it was that told him
this. Heins related, with a deep sigh, which might be given to the
memory of either the ship or its owner, that the vessel had been
wrecked, and was now at the bottom of the sea. This was the other
piece of bad news he had to tell. At least two-thirds of his hearers
asked after the crew, while the rest inquired for the cargo. The cargo
was lost, except a small portion, which had been preserved with
difficulty. The crew had been picked up, only one sailor-boy being
missing. It was from two of them who had found their way home that
Heins had received the tidings of his misfortune.
"One sailor-boy!" repeated Christian. "Do you know how he was
lost? Was he blown from the yards, do you think? Or was he washed
overboard? or did he go down with the ship?"
Heins did not know any particulars of the sailor-boy. But where?
But how? But when did this happen?
It happened where many shipwrecks had happened before, and
many would again, and in the same manner. The vessel had struck
on the Eddystone rock on a stormy night. This was another nuisance
for which the Dutch were indebted to the English. This fatal rock----.
"Did the English make the Eddystone rock?" little Roselyn
inquired, in a low voice, of the pastor. "I thought it was God that
broke up the fountains of the deeps, and fixed the everlasting hills."
Her wiser brother Christian enlightened her.
"God made this rock; but perhaps he made it so that it might be of
use to us, instead of doing us harm, if the English would make the
best use of it. Is not that what Heins means, M. Aymond?"
M. Aymond believed that what Mr. Vanderput had just said was
true; that the English were about to build a light-house on this
dangerous rock, which might thus be made to guide ships into a
British harbour, instead of causing them to perish. He trusted that it
would appear that Heins was mistaken in saying that many more
ships would be lost on that rock; and he hoped that men would learn
in time to make all God's works instruments of blessing to their race.
Christian carried on the speculation.
"And then, perhaps, man's works may not perish by accident
before they are worn out, as this ship did. But yet this was what
happened with one of God's works too,--that sailor-boy. He perished
before he was worn out. But why do people ever wear out, M.
Aymond? Whether a person is drowned at fifteen or dies worn out at
eighty, does not much signify, if God could make them live a
thousand years. Only think of a person living a thousand years, M.
Aymond! He would see cities grow as we see ant-hills rise, while the
sea roared against the dykes as it did at the beginning. He would
see the stars move so often that he would know them all in their
places. He would know almost everything. O! why do not men live a
thousand years? and why does God let a young sailor-boy be lost?"
Gertrude whispered, "All the days of Methuselah were nine
hundred, sixty and nine years; and he died."
"Yes," added the pastor, gravely meeting the kindling eyes of
Christian; "death comes sooner or later; and whether it came soon or
late would be all in all if we were to live no more. But as man's life is
never to end----"
"Ah! I see. If his life is never to end, it does not signify so much
when he passes out of one kind of life into another. I was going to
ask why there should be any death at all. If I made a world, I would---
-"
Christian had talked too eagerly, and now was prevented by his
cough from speaking any more at present. When he recovered his
voice, the pastor turned his attention from the lost sailor-boy to the
lost ship, asking whether it had not answered its purpose in making
several voyages; whether the skill and toil of the artificers had not
been repaid. Christian thought not; and he went on to exhibit as
much as he could of the worked up knowledge and labour which had
in this instance been engulphed by the waves. He seemed so much
irritated, however, by his imperfection in the knowledge of ship-
building, that Gertrude proposed that he should pay her a visit at
Saardam, where he might look down from a window upon the dock-
yard, and witness nearly the whole process without being moved
from his couch. She almost repented the proposal when she saw the
poor boy's rapture; but, happily, no one perceived any objection to
the plan. The little voyage of seven miles could be made perfectly
easy to invalids; and it was quite certain that Christian would be
happy with Gertrude, if anywhere. Heins and the pastor contended
for the charge of Christian, and old Mr. Slyk, the most punctilious of
mourners, allowed that such an indulgence might,--especially with a
view to increased knowledge,--be extended to a sufferer like
Christian, within the days of strict mourning, provided the mother and
the younger children staid at home. Luc clenched his fist on hearing
this, and Roselyn pouted; but their jealousy of their brother soon
vanished when his dreaded pain came on, and they were put out of
the room by their mother, as usual, that they might not become
hardened to the expressions of agony which they could not relieve.
They were heartily glad when the day was nearly over;--when
there was an end of going from the melancholy burial feast in one
room, into the apartment where Gertrude was describing to the now
passive Christian spectacles which they were not to see, and
pleasures which were held to be incompatible with the mourning of
which they already required to be reminded. They were not,
however, allowed to retire in this state of forgetfulness of the
occasion. The pastor's closing prayer, the solemn looks of the
servants, and their mother's silent tears when she laid her hand
upon their heads, left them no disposition for complaint as they stole
away to their beds.
Chapter II.
AN EXCURSION.