Added sections about sizeof on data members and unrestricted unions

git-svn-id: https://cppannotations.svn.sourceforge.net/svnroot/cppannotations/trunk@227 f6dd340e-d3f9-0310-b409-bdd246841980
This commit is contained in:
Frank B. Brokken 2009-07-12 11:21:53 +00:00
parent c7389ef23e
commit 634905e47e
7 changed files with 260 additions and 4 deletions

View file

@ -61,8 +61,8 @@ includefile(classes/intro)
lsubsect(NAMESPACEHDR)(Using namespaces in header files)
includefile(classes/namespaces)
csect(Sizeof applied to class members)
cincludefile(classes/sizeof)
sect(Sizeof applied to class data members (C++0x))
includefile(classes/sizeof)
csect(Unrestricted Unions)
cincludefile(classes/unrestrictedunions)
sect(Unrestricted Unions (C++0x))
includefile(classes/unrestrictedunions)

20
yo/classes/sizeof.yo Normal file
View file

@ -0,0 +1,20 @@
In the i(C++0x standard) the ti(sizeof) operator can be applied to data
members of classes without the need to specify an object as well. Consider:
verb(
class Data
{
std::string d_name;
...
};
)
To obtain the size of tt(Data)'s tt(d_name) member C++0x allows the
following expression:
verb(
sizeof(Data::d_name);
)
However, note that the compiler observes data protection here as
well. tt(Sizeof(Data::d_name)) can only be used where tt(d_name) may be
visible as well, i.e., by tt(Data)'s member functions and friends.
Using tt(sizeof) on data members without specifying objects becomes available
in tt(g++ 4.4).

View file

@ -0,0 +1,14 @@
The i(C++0x standard) allows unions to consist of objects for which a
non-trivial constructor is defined. Here is an example of the use of such an
emi(unrestricted union):
verb(
union Union
{
int u_int;
double u_double;
std::string u_string;
};
)
Before the C++0x standard the tt(u_string) field could not be used.
Unrestricted unions are not yet supported by the tt(g++) compiler.

222
yo/generic.yo Normal file
View file

@ -0,0 +1,222 @@
INCLUDEFILE(mailus)
sect(The Generic Algorithms)
includefile(generic/generic)
lsubsect(ACCU)(accumulate())
includefile(generic/accumulate)
lsubsect(ADJDIFF)(adjacent_difference())
includefile(generic/adjacentdifference)
lsubsect(ADJFIND)(adjacent_find())
includefile(generic/adjacentfind)
lsubsect(BINSRCH)(binary_search())
includefile(generic/binarysearch)
lsubsect(COPY)(copy())
includefile(generic/copy)
lsubsect(COPYBACK)(copy_backward())
includefile(generic/copybackward)
lsubsect(COUNT)(count())
includefile(generic/count)
lsubsect(COUNTIF)(count_if())
includefile(generic/countif)
lsubsect(EQUAL)(equal())
includefile(generic/equal)
lsubsect(EQUALRANGE)(equal_range())
includefile(generic/equalrange)
lsubsect(FILL)(fill())
includefile(generic/fill)
lsubsect(FILLN)(fill_n())
includefile(generic/filln)
lsubsect(FIND)(find())
includefile(generic/find)
lsubsect(FINDEND)(find_end())
includefile(generic/findend)
lsubsect(FINDFIRST)(find_first_of())
includefile(generic/findfirstof)
lsubsect(FINDIF)(find_if())
includefile(generic/findif)
lsubsect(FOREACH)(for_each())
includefile(generic/foreach)
lsubsect(GEN)(generate())
includefile(generic/generate)
lsubsect(GENN)(generate_n())
includefile(generic/generaten)
lsubsect(INCLUDES)(includes())
includefile(generic/includes)
lsubsect(INNERPROD)(inner_product())
includefile(generic/innerproduct)
lsubsect(INMERGE)(inplace_merge())
includefile(generic/inplacemerge)
lsubsect(ITERSWAP)(iter_swap())
includefile(generic/iterswap)
lsubsect(LEXCOMP)(lexicographical_compare())
includefile(generic/lexicographicalcompare)
lsubsect(LOWERBOUND)(lower_bound())
includefile(generic/lowerbound)
lsubsect(MAX)(max())
includefile(generic/max)
lsubsect(MAXEL)(max_element())
includefile(generic/maxelement)
lsubsect(MERGE)(merge())
includefile(generic/merge)
lsubsect(MIN)(min())
includefile(generic/min)
lsubsect(MINEL)(min_element())
includefile(generic/minelement)
lsubsect(MISMATCH)(mismatch())
includefile(generic/mismatch)
lsubsect(NEXTPERM)(next_permutation())
includefile(generic/nextpermutation)
lsubsect(NTHEL)(nth_element())
includefile(generic/nthelement)
lsubsect(PARTSORT)(partial_sort())
includefile(generic/partialsort)
lsubsect(PARTSORTCP)(partial_sort_copy())
includefile(generic/partialsortcopy)
lsubsect(PARTSUM)(partial_sum())
includefile(generic/partialsum)
lsubsect(PARTIT)(partition())
includefile(generic/partition)
lsubsect(PREVPERM)(prev_permutation())
includefile(generic/prevpermutation)
lsubsect(SHUFFLE)(random_shuffle())
includefile(generic/randomshuffle)
lsubsect(REMOVE)(remove())
includefile(generic/remove)
lsubsect(REMOVECP)(remove_copy())
includefile(generic/removecopy)
lsubsect(REMOVECPIF)(remove_copy_if())
includefile(generic/removecopyif)
lsubsect(REMOVEIF)(remove_if())
includefile(generic/removeif)
lsubsect(REPLACE)(replace())
includefile(generic/replace)
lsubsect(REPLACECP)(replace_copy())
includefile(generic/replacecopy)
lsubsect(REPLACECPIF)(replace_copy_if())
includefile(generic/replacecopyif)
lsubsect(REPLACEIF)(replace_if())
includefile(generic/replaceif)
lsubsect(REVERSE)(reverse())
includefile(generic/reverse)
lsubsect(REVERSECP)(reverse_copy())
includefile(generic/reversecopy)
lsubsect(ROTATE)(rotate())
includefile(generic/rotate)
lsubsect(ROTATECP)(rotate_copy())
includefile(generic/rotatecopy)
lsubsect(SEARCH)(search())
includefile(generic/search)
lsubsect(SEARCHN)(search_n())
includefile(generic/searchn)
lsubsect(SETDIF)(set_difference())
includefile(generic/setdifference)
lsubsect(SETINT)(set_intersection())
includefile(generic/setintersection)
lsubsect(SETSYM)(set_symmetric_difference())
includefile(generic/setsymmetricdifference)
lsubsect(SETUNI)(set_union())
includefile(generic/setunion)
lsubsect(SORT)(sort())
includefile(generic/sort)
lsubsect(STABPART)(stable_partition())
includefile(generic/stablepartition)
lsubsect(STABSORT)(stable_sort())
includefile(generic/stablesort)
lsubsect(SWAP)(swap())
includefile(generic/swap)
lsubsect(SWAPRAN)(swap_ranges())
includefile(generic/swapranges)
lsubsect(TRANSFORM)(transform())
includefile(generic/transform)
lsubsect(UNIQUE)(unique())
includefile(generic/unique)
lsubsect(UNIQUECP)(unique_copy())
includefile(generic/uniquecopy)
lsubsect(UPPERBOUND)(upper_bound())
includefile(generic/upperbound)
subsect(Heap algorithms)
includefile(generic/heap)
lsubsubsect(MAKEHEAP)(The `make_heap()' function)
includefile(generic/makeheap)
lsubsubsect(POPHEAP)(The `pop_heap()' function)
includefile(generic/popheap)
lsubsubsect(PUSHHEAP)(The `push_heap()' function)
includefile(generic/pushheap)
lsubsubsect(SORTHEAP)(The `sort_heap()' function)
includefile(generic/sortheap)
lsubsubsect(HEAPDEMO)(An example using the heap functions)
Here is an example showing the various generic algorithms manipulating
heaps:
verbinclude(generic/cc/heap.cc)