mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
trimmed and paren-checked for 10.0.0
This commit is contained in:
parent
f269b883bf
commit
3a423f349b
12 changed files with 48 additions and 22 deletions
|
@ -35,8 +35,6 @@ IFDEF(latex)(latexcommand(
|
|||
\pagestyle{headings}
|
||||
\pagenumbering{arabic}))()
|
||||
|
||||
COMMENT( WIP THREADING
|
||||
|
||||
COMMENT( 1 )
|
||||
lchapter(Overview)(Overview Of The Chapters)
|
||||
includefile(overview)
|
||||
|
@ -113,14 +111,10 @@ COMMENT( 19 )
|
|||
lchapter(GENERIC)(The STL Generic Algorithms)
|
||||
includefile(generic)
|
||||
|
||||
END WIP THREADING)
|
||||
|
||||
COMMENT( 20 )
|
||||
lchapter(THREADING)(Multi Threading)
|
||||
includefile(threading)
|
||||
|
||||
COMMENT( WIP THREADING
|
||||
|
||||
COMMENT( 21 )
|
||||
lchapter(TEMPLATES)(Function Templates)
|
||||
includefile(functiontemplates)
|
||||
|
@ -139,4 +133,3 @@ includefile(concrete)
|
|||
|
||||
IFDEF(latex)(latexcommand(\printindex))()
|
||||
|
||||
END WIP THREADING)
|
||||
|
|
|
@ -27,5 +27,5 @@ multi-threaded programs (cf. chapter ref(THREADING)), thrown exceptions can be
|
|||
transferred between threads after converting tt(std::exception) objects to
|
||||
tt(std::exception_ptr) objects. This proceduce can even be used from inside
|
||||
the default catcher. Refer to section ref(EXCPTR) for further coverage of the
|
||||
class tt(std::exception_ptr)).
|
||||
class tt(std::exception_ptr).
|
||||
|
||||
|
|
|
@ -41,3 +41,21 @@ is possible to use enum class forward declarations.
|
|||
enum class Enum3; // Legal in C++11: default int type is used
|
||||
enum class Enum4: char; // Legal in C++11: explicitly declared type
|
||||
)
|
||||
|
||||
A sequence of symbols of a strongly typed enumeration can also be
|
||||
indicated in a tt(switch) using the i(ellipsis) syntax, as shown in the next
|
||||
example:
|
||||
verb(
|
||||
SafeEnum enumValue();
|
||||
|
||||
switch (enumValue())
|
||||
{
|
||||
case SafeEnum::NOT_OK ... SafeEnum::OK:
|
||||
cout << "Status is known\n";
|
||||
break;
|
||||
|
||||
default:
|
||||
cout << "Status unknown\n";
|
||||
break;
|
||||
}
|
||||
)
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
printf("Saw EOF\n");
|
||||
break;
|
||||
|
||||
case '0' ... '9':
|
||||
printf("Saw number character %c\n", c);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Saw other character, hex value 0x%2x\n", c);
|
||||
}
|
||||
|
|
|
@ -73,6 +73,13 @@ the enumeration type is needed, as illustrated by the following piece of code:
|
|||
ds.setTraversal(DataStructure::BACKWARD);
|
||||
}
|
||||
)
|
||||
In the above example the constant tt(DataStructure;:FORWARD) was used to
|
||||
specify a value of an enum defined in the class tt(DataStructure). Instead of
|
||||
tt(DataStructure::FORWARD) the construction tt(ds.FORWARD) is also
|
||||
accepted. In my opinion this syntactic liberty is ugly: tt(FORWARD) is a
|
||||
symbolic value that is defined at the class level; it's not a member of tt(ds),
|
||||
which is suggested by the use of the member selector operator.
|
||||
|
||||
Only if tt(DataStructure) defines a nested class tt(Nested), in
|
||||
turn defining the enumeration tt(Traversal), the two class scopes are
|
||||
required. In that case the latter example should have been coded as follows:
|
||||
|
@ -87,3 +94,5 @@ required. In that case the latter example should have been coded as follows:
|
|||
ds.setTraversal(DataStructure::Nested::BACKWARD);
|
||||
}
|
||||
)
|
||||
Here the construction tt(DataStructure::Nested::Traversal localMode =
|
||||
ds.Nested::FORWARD) could also be used. I would avoid it.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
In this section the function template hi(async)tt(std::async) is
|
||||
covered. tt(Async) is used to start asynchronous tasks, returning values (or
|
||||
tt(void) to the calling thread, which is hard to realize merely using the
|
||||
tt(void)) to the calling thread, which is hard to realize merely using the
|
||||
tt(std::thread) class.
|
||||
|
||||
Before using the function tt(async) the tthi(future) header file must be
|
||||
|
@ -88,15 +88,15 @@ function (see also the remarks below).
|
|||
argument must be references, pointers or move-constructible objects:
|
||||
itemization(
|
||||
it() When a
|
||||
member function is specified, then the object for which the member
|
||||
function is called must be a named object, an anonymous object, or a
|
||||
pointer to a named object.
|
||||
member function is specified, then the object for which the member
|
||||
function is called must be a named object, an anonymous object, or a
|
||||
pointer to a named object.
|
||||
it() When a named object is passed to the tt(async) function template then
|
||||
copy construction is used to construct a copy of the argument which is
|
||||
then forwarded to the thread-launcher.
|
||||
copy construction is used to construct a copy of the argument which is
|
||||
then forwarded to the thread-launcher.
|
||||
it() When an anonymous object is passed to the tt(async) function template
|
||||
then move construction is used to forward the anonymous object to the
|
||||
thread launcher.
|
||||
then move construction is used to forward the anonymous object to the
|
||||
thread launcher.
|
||||
)
|
||||
Once the thread itself starts another move construction is used to construct
|
||||
an object for the duration of the thread. When a pointer to an object is
|
||||
|
|
|
@ -24,7 +24,7 @@ try
|
|||
auto ep = current_exception();
|
||||
if (ep == 0)
|
||||
cerr << "current_exc. equals null if an int is thrown\n";
|
||||
rethrow_exception(ep);
|
||||
rethrow_exception(ep);
|
||||
}
|
||||
}
|
||||
catch (int x)
|
||||
|
@ -57,7 +57,7 @@ try
|
|||
// p.set_exception(make_exception_ptr(string("hello")));
|
||||
|
||||
rethrow_exception(make_exception_ptr(12));
|
||||
|
||||
|
||||
}
|
||||
catch (int x)
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ int main()
|
|||
);
|
||||
auto bill = serviceTask.get_future();
|
||||
condition.notify_one();
|
||||
cout << "Bill for servicing a " << car <<
|
||||
cout << "Bill for servicing a " << car <<
|
||||
": EUR " << bill.get() << '\n';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,4 +17,3 @@ int main()
|
|||
cout << p.get_future().get() << '\n';
|
||||
}
|
||||
//=
|
||||
|
||||
|
|
|
@ -35,4 +35,3 @@ int main()
|
|||
}
|
||||
}
|
||||
//=
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ int main()
|
|||
{
|
||||
std::promise<int> promise;
|
||||
promise.set_value(15);
|
||||
|
||||
|
||||
auto fut = promise.get_future();
|
||||
auto shared1 = fut.share();
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
This section is modified when the first or second part of the version number
|
||||
changes (and sometimes for the third part as well).
|
||||
itemization(
|
||||
it() Version 10.0.0 adds a new chapter about multi threading, which is
|
||||
formally supported since the C++11 standard. In addition some minor
|
||||
topics (e.g., tt(std::distance), some new syntax elements) were added
|
||||
to the annotations().
|
||||
it() In version 9.9.0 sections in chapter ref(STL) about specifying
|
||||
absolute and relative time were rewritten and moved to sections of
|
||||
their own. Sections about condition variablles were also rewritten.
|
||||
|
|
Loading…
Reference in a new issue