Download full C++ templates: the complete guide Second Edition David Vandevoorde & Nicolai M. Josuttis & Douglas Gregor ebook all chapters
Download full C++ templates: the complete guide Second Edition David Vandevoorde & Nicolai M. Josuttis & Douglas Gregor ebook all chapters
Download full C++ templates: the complete guide Second Edition David Vandevoorde & Nicolai M. Josuttis & Douglas Gregor ebook all chapters
com
https://textbookfull.com/product/c-templates-the-complete-
guide-second-edition-david-vandevoorde-nicolai-m-josuttis-
douglas-gregor/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/c-17-the-complete-guide-nicolai-m-
josuttis/
textboxfull.com
https://textbookfull.com/product/c-move-semantics-the-complete-guide-
nicolai-m-josuttis/
textboxfull.com
https://textbookfull.com/product/primary-mathematics-
textbook-2b-jennifer-hoerst/
textboxfull.com
https://textbookfull.com/product/handbook-of-macroeconomics-
volume-2a-2b-set-1st-edition-john-b-taylor/
textboxfull.com
Blender 2D Animation: The Complete Guide to the Grease
Pencil: Second Edition John M. Blain
https://textbookfull.com/product/blender-2d-animation-the-complete-
guide-to-the-grease-pencil-second-edition-john-m-blain/
textboxfull.com
https://textbookfull.com/product/complete-guide-to-the-national-park-
lodges-david-scott/
textboxfull.com
https://textbookfull.com/product/the-lstas-complete-credit-agreement-
guide-second-edition-michael-bellucci/
textboxfull.com
https://textbookfull.com/product/complete-guide-to-the-national-park-
lodges-9th-edition-david-scott/
textboxfull.com
C++ Templates
The Complete Guide
Second Edition
David Vandevoorde
Nicolai M. Josuttis
Douglas Gregor
Preface
Acknowledgments for the Second Edition
Acknowledgments for the First Edition
About This Book
What You Should Know Before Reading This Book
Overall Structure of the Book
How to Read This Book
Some Remarks About Programming Style
The C++11, C++14, and C++17 Standards
Example Code and Additional Information
Feedback
1 Function Templates
1.1 A First Look at Function Templates
1.1.1 Defining the Template
1.1.2 Using the Template
1.1.3 Two-Phase Translation
1.2 Template Argument Deduction
1.3 Multiple Template Parameters
1.3.1 Template Parameters for Return Types
1.3.2 Deducing the Return Type
1.3.3 Return Type as Common Type
1.4 Default Template Arguments
1.5 Overloading Function Templates
1.6 But, Shouldn’t We …?
1.6.1 Pass by Value or by Reference?
1.6.2 Why Not inline?
1.6.3 Why Not constexpr?
1.7 Summary
2 Class Templates
2.1 Implementation of Class Template Stack
2.1.1 Declaration of Class Templates
2.1.2 Implementation of Member Functions
2.2 Use of Class Template Stack
2.3 Partial Usage of Class Templates
2.3.1 Concepts
2.4 Friends
2.5 Specializations of Class Templates
2.6 Partial Specialization
2.7 Default Class Template Arguments
2.8 Type Aliases
2.9 Class Template Argument Deduction
2.10 Templatized Aggregates
2.11 Summary
4 Variadic Templates
4.1 Variadic Templates
4.1.1 Variadic Templates by Example
4.1.2 Overloading Variadic and Nonvariadic Templates
4.1.3 Operator sizeof…
4.2 Fold Expressions
4.3 Application of Variadic Templates
4.4 Variadic Class Templates and Variadic Expressions
4.4.1 Variadic Expressions
4.4.2 Variadic Indices
4.4.3 Variadic Class Templates
4.4.4 Variadic Deduction Guides
4.4.5 Variadic Base Classes and using
4.5 Summary
5 Tricky Basics
5.1 Keyword typename
5.2 Zero Initialization
5.3 Using this->
5.4 Templates for Raw Arrays and String Literals
5.5 Member Templates
5.5.1 The .template Construct
5.5.2 Generic Lambdas and Member Templates
5.6 Variable Templates
5.7 Template Template Parameters
5.8 Summary
8 Compile-Time Programming
8.1 Template Metaprogramming
8.2 Computing with constexpr
8.3 Execution Path Selection with Partial Specialization
8.4 SFINAE (Substitution Failure Is Not An Error)
8.4.1 Expression SFINAE with decltype
8.5 Compile-Time if
8.6 Summary
11 Generic Libraries
11.1 Callables
11.1.1 Supporting Function Objects
11.1.2 Dealing with Member Functions and Additional
Arguments
11.1.3 Wrapping Function Calls
11.2 Other Utilities to Implement Generic Libraries
11.2.1 Type Traits
11.2.2 std::addressof()
11.2.3 std::declval()
11.3 Perfect Forwarding Temporaries
11.4 References as Template Parameters
11.5 Defer Evaluations
11.6 Things to Consider When Writing Generic Libraries
11.7 Summary
12 Fundamentals in Depth
12.1 Parameterized Declarations
12.1.1 Virtual Member Functions
12.1.2 Linkage of Templates
12.1.3 Primary Templates
12.2 Template Parameters
12.2.1 Type Parameters
12.2.2 Nontype Parameters
12.2.3 Template Template Parameters
12.2.4 Template Parameter Packs
12.2.5 Default Template Arguments
12.3 Template Arguments
12.3.1 Function Template Arguments
12.3.2 Type Arguments
12.3.3 Nontype Arguments
12.3.4 Template Template Arguments
12.3.5 Equivalence
12.4 Variadic Templates
12.4.1 Pack Expansions
12.4.2 Where Can Pack Expansions Occur?
12.4.3 Function Parameter Packs
12.4.4 Multiple and Nested Pack Expansions
12.4.5 Zero-Length Pack Expansions
12.4.6 Fold Expressions
12.5 Friends
12.5.1 Friend Classes of Class Templates
12.5.2 Friend Functions of Class Templates
12.5.3 Friend Templates
12.6 Afternotes
13 Names in Templates
13.1 Name Taxonomy
13.2 Looking Up Names
13.2.1 Argument-Dependent Lookup
13.2.2 Argument-Dependent Lookup of Friend Declarations
13.2.3 Injected Class Names
13.2.4 Current Instantiations
13.3 Parsing Templates
13.3.1 Context Sensitivity in Nontemplates
13.3.2 Dependent Names of Types
13.3.3 Dependent Names of Templates
13.3.4 Dependent Names in Using Declarations
13.3.5 ADL and Explicit Template Arguments
13.3.6 Dependent Expressions
13.3.7 Compiler Errors
13.4 Inheritance and Class Templates
13.4.1 Nondependent Base Classes
13.4.2 Dependent Base Classes
13.5 Afternotes
14 Instantiation
14.1 On-Demand Instantiation
14.2 Lazy Instantiation
14.2.1 Partial and Full Instantiation
14.2.2 Instantiated Components
14.3 The C++ Instantiation Model
14.3.1 Two-Phase Lookup
14.3.2 Points of Instantiation
14.3.3 The Inclusion Model
14.4 Implementation Schemes
14.4.1 Greedy Instantiation
14.4.2 Queried Instantiation
14.4.3 Iterated Instantiation
14.5 Explicit Instantiation
14.5.1 Manual Instantiation
14.5.2 Explicit Instantiation Declarations
14.6 Compile-Time if Statements
14.7 In the Standard Library
14.8 Afternotes
17 Future Directions
17.1 Relaxed typename Rules
17.2 Generalized Nontype Template Parameters
17.3 Partial Specialization of Function Templates
17.4 Named Template Arguments
17.5 Overloaded Class Templates
17.6 Deduction for Nonfinal Pack Expansions
17.7 Regularization of void
17.8 Type Checking for Templates
17.9 Reflective Metaprogramming
17.10 Pack Facilities
17.11 Modules
Part III: Templates and Design
19 Implementing Traits
19.1 An Example: Accumulating a Sequence
19.1.1 Fixed Traits
19.1.2 Value Traits
19.1.3 Parameterized Traits
19.2 Traits versus Policies and Policy Classes
19.2.1 Traits and Policies: What’s the Difference?
19.2.2 Member Templates versus Template Template
Parameters
19.2.3 Combining Multiple Policies and/or Traits
19.2.4 Accumulation with General Iterators
19.3 Type Functions
19.3.1 Element Types
19.3.2 Transformation Traits
19.3.3 Predicate Traits
19.3.4 Result Type Traits
19.4 SFINAE-Based Traits
19.4.1 SFINAE Out Function Overloads
19.4.2 SFINAE Out Partial Specializations
19.4.3 Using Generic Lambdas for SFINAE
19.4.4 SFINAE-Friendly Traits
19.5 IsConvertibleT
19.6 Detecting Members
19.6.1 Detecting Member Types
19.6.2 Detecting Arbitrary Member Types
19.6.3 Detecting Nontype Members
19.6.4 Using Generic Lambdas to Detect Members
19.7 Other Traits Techniques
19.7.1 If-Then-Else
19.7.2 Detecting Nonthrowing Operations
19.7.3 Traits Convenience
19.8 Type Classification
19.8.1 Determining Fundamental Types
19.8.2 Determining Compound Types
19.8.3 Identifying Function Types
19.8.4 Determining Class Types
19.8.5 Determining Enumeration Types
19.9 Policy Traits
19.9.1 Read-Only Parameter Types
19.10 In the Standard Library
19.11 Afternotes
23 Metaprogramming
23.1 The State of Modern C++ Metaprogramming
23.1.1 Value Metaprogramming
23.1.2 Type Metaprogramming
23.1.3 Hybrid Metaprogramming
23.1.4 Hybrid Metaprogramming for Unit Types
23.2 The Dimensions of Reflective Metaprogramming
23.3 The Cost of Recursive Instantiation
23.3.1 Tracking All Instantiations
23.4 Computational Completeness
23.5 Recursive Instantiation versus Recursive Template
Arguments
23.6 Enumeration Values versus Static Constants
23.7 Afternotes
24 Typelists
24.1 Anatomy of a Typelist
24.2 Typelist Algorithms
24.2.1 Indexing
24.2.2 Finding the Best Match
24.2.3 Appending to a Typelist
24.2.4 Reversing a Typelist
24.2.5 Transforming a Typelist
24.2.6 Accumulating Typelists
24.2.7 Insertion Sort
24.3 Nontype Typelists
24.3.1 Deducible Nontype Parameters
24.4 Optimizing Algorithms with Pack Expansions
24.5 Cons-style Typelists
24.6 Afternotes
25 Tuples
25.1 Basic Tuple Design
25.1.1 Storage
25.1.2 Construction
25.2 Basic Tuple Operations
25.2.1 Comparison
25.2.2 Output
25.3 Tuple Algorithms
25.3.1 Tuples as Typelists
25.3.2 Adding to and Removing from a Tuple
25.3.3 Reversing a Tuple
25.3.4 Index Lists
25.3.5 Reversal with Index Lists
25.3.6 Shuffle and Select
25.4 Expanding Tuples
25.5 Optimizing Tuple
25.5.1 Tuples and the EBCO
25.5.2 Constant-time get()
25.6 Tuple Subscript
25.7 Afternotes
26 Discriminated Unions
26.1 Storage
26.2 Design
26.3 Value Query and Extraction
26.4 Element Initialization, Assignment and Destruction
26.4.1 Initialization
26.4.2 Destruction
26.4.3 Assignment
26.5 Visitors
26.5.1 Visit Result Type
26.5.2 Common Result Type
26.6 Variant Initialization and Assignment
26.7 Afternotes
27 Expression Templates
27.1 Temporaries and Split Loops
27.2 Encoding Expressions in Template Arguments
27.2.1 Operands of the Expression Templates
27.2.2 The Array Type
27.2.3 The Operators
27.2.4 Review
27.2.5 Expression Templates Assignments
27.3 Performance and Limitations of Expression Templates
27.4 Afternotes
28 Debugging Templates
28.1 Shallow Instantiation
28.2 Static Assertions
28.3 Archetypes
28.4 Tracers
28.5 Oracles
28.6 Afternotes
Appendixes
B Value Categories
B.1 Traditional Lvalues and Rvalues
B.1.1 Lvalue-to-Rvalue Conversions
B.2 Value Categories Since C++11
B.2.1 Temporary Materialization
B.3 Checking Value Categories with decltype
B.4 Reference Types
C Overload Resolution
C.1 When Does Overload Resolution Kick In?
C.2 Simplified Overload Resolution
C.2.1 The Implied Argument for Member Functions
C.2.2 Refining the Perfect Match
C.3 Overloading Details
C.3.1 Prefer Nontemplates or More Specialized Templates
C.3.2 Conversion Sequences
C.3.3 Pointer Conversions
C.3.4 Initializer Lists
C.3.5 Functors and Surrogate Functions
C.3.6 Other Overloading Contexts
E Concepts
E.1 Using Concepts
E.2 Defining Concepts
E.3 Overloading on Constraints
E.3.1 Constraint Subsumption
E.3.2 Constraints and Tag Dispatching
E.4 Concept Tips
E.4.1 Testing Concepts
E.4.2 Concept Granularity
E.4.3 Binary Compatibility
Bibliography
Forums
Books and Web Sites
Glossary
Index
Preface
“And the wedding was held, and the merry bells rung,
And all the good people they danced and they sung,
And feasted and frolick’d I can’t tell how long.”
A Dwarf from Sweden was the next to be invited to the stool, and
sitting down he began to tell how a troll was enabled to do a kindly
service to a poor lad who had saved him from a fierce werewolf.
“My story,” he said, “shall be called
The Troll’s Hammer
There was once a great famine in the country; the poor could not
procure the necessaries of life, and even the rich suffered great
privation. At that time a poor peasant dwelt out on the heath. One
day he said to his son, that he could no longer support him, and that
he must go out in the world, and provide for himself. Niels,
therefore, left home and wandered forth.
Towards evening he found himself in a large forest, and climbed
up into a tree, lest the wild beasts might do him harm during the
night. When he had slept about an hour or perhaps more, a little
man came running towards the tree. He was hunch-backed, had
crooked legs, a long beard, and a red cap on his head. He was
pursued by a werewolf, which attacked him just under the tree in
which Niels was sitting. The little man began to scream; he bit and
scratched, and defended himself as well as he could, but all to no
purpose, the werewolf was his master, and would have torn him in
pieces, if Niels had not sprung down from the tree, and come to his
assistance. As soon as the werewolf saw that he had two to contend
with, he was afraid, and fled back into the forest.
The Troll then said to Niels: “Thou hast preserved my life, and
done me good service; in return I will also give thee something that
will be beneficial to thee. See! here is a hammer, and all the smith’s
work which thou doest with it, no one shall be able to equal.
Continue thy way, and things will go better than thou thinkest.”
When the Troll had spoken these words, he sank into the ground
before Niels.
The next day the boy wandered on, until he came to the
neighbourhood of the royal palace, and here he engaged himself to
a smith.
Now it just happened, that a few days previously a thief had
broken into the king’s treasury and stolen a large bag of money. All
the smiths in the city were, therefore, sent for to the palace, and the
king promised that he who could make the best and securest lock,
should be appointed court locksmith, and have a considerable
reward into the bargain. But the lock must be finished in eight days,
and so constructed that it could not be picked by any one.
When the smith, with whom Niels lived, returned home and
related this, the boy thought he should like to try whether his
hammer really possessed those qualities which the Troll had said. He
therefore begged his master to allow him to make a lock, and
promised that it should be finished by the appointed time. Although
the smith had no great opinion of the boy’s ability, he, nevertheless,
allowed him to make the trial. Niels then requested to have a
separate workshop, locked himself in, and then began hammering
the iron. One day went, and then another, and the master began to
be inquisitive; but Niels let no one come in, and the smith was
obliged to remain outside, and peep through the key-hole. The work,
however, succeeded far better than the boy himself had expected;
and, without his really knowing how it came to pass, the lock was
finished on the evening of the third day.
The following morning he went down to his master and asked him
for some money. “Yesterday I worked hard,” said he, “and to-day I
will make myself merry.” Hereupon he went out of the city, and did
not return to the workshop till late in the evening. The next day he
did the same, and idled away the rest of the week. His master was,
consequently, very angry, and threatened to turn him away, unless
he finished his work at the appointed time. But Niels told him to be
quite easy, and engaged that his lock should be the best. When the
day arrived, Niels brought his work forth, and carried it up to the
palace, and it appeared that his lock was so ingenious and delicately
made, that it far excelled all the others. The consequence was, that
Niels’ master was acknowledged as the most skilful, and received the
promised office and reward.
The smith was delighted, but he took good care not to confess to
any one who it was that had made the curious lock. He now received
one work after another from the king, and let Niels do them all, and
he soon became a wealthy man.
In the meantime, the report spread from place to place of the
ingenious lock the king had got for his treasury. Travellers came from
a great distance to see it, and it happened that a foreign king came
also to the palace. When he had examined the work for a long time,
he said, that the man who could make such a lock deserved to be
honoured and respected. “But however good a smith he may be,”
added the king, “I have got his master at home.” He continued
boasting in this manner, till at length the king offered to wager with
him which could execute the most skilful piece of workmanship. The
smiths were sent for, and the two kings determined that each smith
should make a knife. He who won was to have a considerable
reward. The smith related to Niels what had passed, and desired him
to try whether he could not make as good a knife as he had a lock.
Niels promised that he would, although his last work had not
benefited him much. The smith was in truth an avaricious man, and
treated him so niggardly, that at times he had not enough to eat and
drink.
It happened one day, as Niels was gone out to buy steel to make
the knife, that he met a man from his own village, and, in the course
of conversation, learnt from him that his father went begging from
door to door, and was in great want and misery. When Niels heard
this he asked his master for some money to help his father; but his
master answered, that he should not have a shilling before he had
made the knife. Hereupon Niels shut himself up in the workshop,
worked a whole day, and, as on the former occasion, the knife was
made without his knowing how it happened.
When the day arrived on which the work was to be exhibited,
Niels dressed himself in his best clothes, and went with his master
up to the palace, where the two kings were expecting them. The
strange smith first showed his knife. It was so beautiful, and so
curiously wrought, that it was a pleasure to look at it; it was,
moreover, so sharp and well tempered, that it could cut through a
millstone to the very centre, as if it had been only a cheese, and that
without the edge being in the least blunted. Niels’ knife, on the
contrary, looked very poor and common. The king already began to
think he had lost his wager, and spoke harshly to the master-smith,
when his boy begged leave to examine the stranger’s knife a little
more closely. After having looked at it for some time, he said: “This
is a beautiful piece of workmanship which you have made, and
shame on those who would say otherwise; but my master is,
nevertheless, your superior, as you shall soon experience.” Saying
this, he took the stranger’s knife and split it lengthwise from the
point to the handle with his own knife, as easily as one splits a twig
of willow. The kings could scarcely believe their eyes; and the
consequence was, that the Danish smith was declared the victor, and
got a large bag of money to carry home with him.
When Niels asked for payment, his master refused to give him
anything, although he well knew that the poor boy only wanted the
money to help his father. Upon this Niels grew angry, went up to the
king, and related the whole story to him, how it was he who had
made both the lock and the knife. The master was now called, but
he denied everything, and accused Niels of being an idle boy, whom
he had taken into his service out of charity and compassion.
“The truth of this story we shall soon find out,” said the king, who
sided with the master. “Since thou sayest it is thou who hast made
this wonderful knife, and thy master says it is he who has done it, I
will adjudge each of you to make a sword for me within eight days.
He who can make the most perfect one shall be my master-smith;
but he who loses, shall forfeit his life.”
Niels was well satisfied with this agreement. He went home,
packed up all his things, and bade his master farewell. The smith
was now in great straits, and would gladly have made all good
again; but Niels appeared not to understand him, and went his way,
and engaged with another master, where he cheerfully began to
work on the sword.
When the appointed day arrived, they both met at the palace, and
the master produced a sword of the most elaborate workmanship
that any one could wish to see, besides being inlaid with gold, and
set with precious stones. The king was greatly delighted with it.
“Now, little Niels,” said he, “what dost thou say to this sword?”
“Certainly,” answered the boy, “it is not so badly made as one
might expect from such a bungler.”
“Canst thou show anything like it?” asked the king.
“I believe I can,” answered Niels.
“Well, produce thy sword; where is it?” said the king.
“I have it in my waistcoat pocket,” replied Niels.
Hereupon there was a general laugh, which was increased when
they saw the boy take a little packet out of his waistcoat pocket.
Niels opened the paper, in which the blade was rolled up like a
watch-spring. “Here is my work,” said he, “will you just cut the
thread, master?”
The smith did it willingly, and in a moment the blade straightened
itself and struck him in the face.
Niels took out of his other pocket a hilt of gold, and screwed it fast
to the blade; then presented the sword to the king; and all present
were obliged to confess that they never before had seen such
matchless workmanship.
Niels was unanimously declared the victor, and the master was
obliged to acknowledge that the boy had made both the lock and
the knife.
The king in his indignation would have had the master executed, if
the boy had not begged for mercy on the culprit. Niels received a
handsome reward from the king, and from that day all the work
from the palace was intrusted to him. He took his old father to
reside with him, and lived in competence and happiness till his
death.
When the Swedish Troll had gone back to his place after telling
with much self-satisfaction how one of his fellows had befriended the
poor apprentice, a Norwegian fairy came forward to tell how three of
her companions had similarly served a young princess, and she
named her story
The three little Crones, each with
Something big
There was once a king’s son and a king’s daughter who dearly loved
each other. The young princess was good and fair, and well spoken
of by all, but her disposition was more inclined to pleasure and
dissipation than to handiworks and domestic occupations. To the old
queen this appeared very wrong, and she said she would have no
one for a daughter-in-law that was not as skilled in such matters as
she herself had been in her youth. She therefore opposed the
prince’s marriage in all sorts of ways.
As the queen would not recall her words, the prince went to her
and said, it would be well to make a trial whether the princess were
not as skilful as the queen herself. This seemed to every one a very
rash proposal, seeing that the prince’s mother was a very diligent,
laborious person, and span and sewed and wove both night and day,
so that no one ever saw her like. The prince, however, carried his
point; the fair princess was sent into the maiden’s bower, and the
queen sent her a pound of flax to spin. But the flax was to be spun
ere dawn of day, otherwise the damsel was never more to think of
the prince for a husband.
When left alone the princess found herself very ill at ease; for she
well knew that she could not spin the queen’s flax, and yet trembled
at the thought of losing the prince, who was so dear to her. She
therefore wandered about the apartment and wept, incessantly
wept. At this moment the door was opened very softly, and there
stepped in a little, little woman of singular appearance and yet more
singular manners. The little woman had enormously large feet, at
which every one who saw her must be wonderstruck. She greeted
the princess with: “Peace be with you!” “And peace with you!”
answered the princess. The old woman then asked: “Why is the fair
damsel so sorrowful to-night?” The princess answered: “I may well
be sorrowful. The queen has commanded me to spin a pound of
flax: if I have not completed it before dawn, I lose the young prince
whom I love so dearly.” The old woman then said: “Be of good
cheer, fair maiden; if there is nothing else, I can help you; but then
you must grant me a request which I will name.” At these words the
princess was overjoyed, and asked what it was the old woman
desired. “I am called,” she said, “Mother Bigfoot; and I require for
my aid no other reward than to be present at your wedding. I have
not been at a wedding since the queen your mother-in-law stood as
bride.” The princess readily granted her desire, and they parted. The
princess then lay down to sleep, but could not close her eyes the
whole livelong night.
Early in the morning, before dawn, the door was opened, and the
little woman again entered. She approached the king’s daughter and
handed to her a bundle of yarn, as white as snow and as fine as a
cobweb, saying, “See! such beautiful yarn I have not spun since I
span for the queen, when she was about to be married; but that was
long, long ago.” Having so spoken the little woman disappeared, and
the princess fell into a refreshing slumber, but she had not slept long
when she was awakened by the old queen, who was standing by her
bed, and who asked her whether the flax were all spun. The
princess said that it was, and handed the yarn to her. The queen
must needs appear content, but the princess could not refrain from
observing that her apparent satisfaction did not proceed from good-
will.
Before the day was over, the queen said she would put the
princess to yet another proof. For this purpose she sent the yarn to
the maiden-bower together with a yarn-roll and other implements,
and ordered the princess to weave it into a web; but which must be
ready before sunrise; if not, the damsel must never more think of
the young prince.
When the princess was alone, she again felt sad at heart; for she
knew that she could not weave the queen’s yarn, and yet less
reconcile herself to the thought of losing the prince to whom she
was so dear. She therefore wandered about the apartment and wept
bitterly. At that moment the door was opened softly, softly, and in
stepped a very little woman, of singular figure and still more singular
manners. The little woman had an enormously large back, so that
every one who saw her must be struck with astonishment. She, too,
greeted the princess with: “Peace be with you!” and received for
answer: “Peace with you!” The old woman said: “Why is the fair
damsel so sad and sorrowful?” “I may well be sorrowful,” answered
the princess. “The queen has commanded me to weave all this yarn
into a web; and if I have not completed it by the morning before
sunrise, I shall lose the prince, who loves me so dearly.” The woman
then said: “Be comforted, fair damsel; if it is nothing more, I will
help you. But then you must consent to one condition, which I will
name to you.” At these words the princess was highly delighted, and
asked what the condition might be. “I am called Mother Bigback,
and I desire no other reward than to be at your wedding. I have not
been to any wedding since the queen your mother-in-law stood as
bride.” The king’s daughter readily granted this request, and the little
woman departed. The princess then lay down to sleep, but was
unable to close her eyes the whole night.
In the morning, before daybreak, the door was opened and the
little woman entered. She approached the princess, and handed to
her a web white as snow and close as a skin, so that its like was
never seen. The old woman said: “See! such even threads I have
never woven since I wove for the queen, when she was about to be
married; but that was long, long ago.” The woman then
disappeared, and the princess fell into a short slumber, but from
which she was roused by the old queen, who stood by her bed, and
inquired whether the web were ready. The princess told her that it
was, and handed to her the beautiful piece of weaving. The queen
must now appear content for the second time; but the princess
could easily see that she was not so from good-will.
The king’s daughter now flattered herself that she should be put
to no further trial; but the queen was of a different opinion; for she
shortly after sent the web down to the maiden-bower with the
message, that the princess should make it into shirts for the prince.
The shirts were to be ready before sunrise, otherwise the damsel
must never hope to have the young prince for a husband.
When the princess was alone, she felt sad at heart; for she knew
that she could not sew the queen’s web, and yet could not think of
losing the king’s son, to whom she was so dear. She therefore
wandered about the chamber, and shed a flood of tears. At this
moment, the door was softly, softly opened, and in stepped a very
little woman of most extraordinary appearance and still more
extraordinary manners. The little woman had an enormously large
thumb, so that every one who saw it must be wonderstruck. She
also greeted the princess with: “Peace be with you,” and likewise
received for answer: “Peace with you.” She then asked the young
damsel why she was so sad and lonely. “I may well be sad,”
answered the princess. “The queen has commanded me to make
this web into shirts for the king’s son; and if I have not finished
them to-morrow before sunrise, I shall lose my beloved prince, who
holds me so dear.” The woman then said: “Be of good cheer, fair
maiden; if it is nothing more, I can help you. But then you must
agree to a condition, which I will mention.” At these words the
princess was overjoyed, and asked the little woman what it was she
wished. “I am,” answered she, “called Mother Bigthumb, and I desire
no other reward than that I may be present at your wedding. I have
not been at a wedding since the queen your mother-in-law stood as
bride.” The princess willingly assented to this condition, and the little
woman departed. But the princess lay down to sleep, and slept so
soundly that she did not dream even once of her dear prince.
Early in the morning, before the sun had risen, the door was
opened, and the little woman entered. She approached the bed,
awakened the princess, and gave her some shirts that were sewed
and stitched so curiously that their like was never seen. The old
woman said: “See! so beautifully as this I have not sewn since I
sewed for the queen, when she was about to stand as bride. But
that was long, long ago.” With these words the little woman
disappeared; for the queen was then at the door, being just come to
inquire whether the shirts were ready. The king’s daughter said that
they were, and handed her the beautiful work. At the sight of them
the queen was so enraged that her eyes flashed with fury. She said:
“Well! take him then. I could never have imagined that thou wast so
clever as thou art.” She then went her way, slamming the door after
her.
The king’s son and the king’s daughter were now
to be united, as the queen had promised, and great
preparations were made for the wedding. But the
joy of the princess was not without alloy, when she
thought of the singular guests that were to be
present. When some time had elapsed, and the
wedding was being celebrated in the good old
fashion, yet not one of the little old women
appeared; although the bride looked about in every
direction. At length, when it was growing late, and
the guests were going to table, the princess
discerned the three little women, as they sat in a
corner of the dining hall, at a table by themselves. At the same
moment the king stepped up to them, and inquired who they were,
as he had never seen them before. The eldest of the three
answered: “I am called Mother Bigfoot, and have such large feet
because I have been obliged to sit spinning so much in my time.”
“Oho!” said the king, “if such be the consequence, my son’s wife
shall never spin another thread.” Then turning to the second little
woman, he inquired the cause of her uncommon appearance. The
old woman answered: “I am called Mother Bigback, and am so
broad behind because I have been obliged to sit weaving so much in
my time.” “Oho!” said the king, “then my son’s wife shall weave no
more.” Lastly, turning to the third old woman, he asked her name;
when Mother Bigthumb, rising from her seat, told him that she had
got so large a thumb because she had sewed so much in her time.
“Oho!” said the king, “then my son’s wife shall never sew another
stitch.” Thus the fair princess obtained the king’s son, and also
escaped from spinning, and weaving, and sewing for all the rest of
her life.
When the wedding was over, the three little women went their way,
and no one knew whither they went, nor whence they came. The
prince lived happy and content with his consort, and all passed on
smoothly and peaceably; only the princess was not so industrious as
her strict mother-in-law.
The fairies are always glad when people do not find out who it is
that has benefited them,—for of course Mother Bigfoot, Mother
Bigback, and Mother Bigthumb were really fairies in disguise,—and
were therefore pleased at the end of the Norwegian fairy’s tale.
“Now,” said Titania, and of course her word was law, “I think I
should like a song. Nymphidia, sing to us.” Nymphidia at once stood
up on the stool and all the Queen’s maids of honour stood around it
as they sang
The Queen’s Song
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com