diff --git a/doc/optional.html b/doc/optional.html index 8ed169f..9c76a8b 100644 --- a/doc/optional.html +++ b/doc/optional.html @@ -4,7 +4,7 @@
- +In C++, we can declare an object (a variable) of type T, and we can give this variable
an initial value (through an initializer. (c.f. 8.5)).
- When a declaration includes a non-empty inilializer (an initial value is given), it is said that
+ When a declaration includes a non-empty initializer (an initial value is given), it is said that
the object has been initialized.
If the declaration uses an empty initializer (no initial value is given),
and neither default nor value initialization applies, it is said that the object is
@@ -103,7 +103,7 @@ if ( p.second )
the value of an uninitialized object is undefined behaviour. That is,
when a variable is declared as optional<T> and no initial value is given,
the variable is formally uninitialized. A formally uninitialized optional object has conceptually
- no value at all and this situation can be tested at runtime. It is formally undefined behvaiour
+ no value at all and this situation can be tested at runtime. It is formally undefined behaviour
to try to access the value of an uninitialized optional. An uninitialized optional can be assigned a value, in which case its
initialization state changes to initialized. And given the formal treatment of initialization
states in optional objects, it is even possible to
@@ -114,7 +114,7 @@ if ( p.second )
information to tell if an object has been effectively initialized.
One of the typical ways in which this has been historically
dealt with is via a special value: EOF,npos,-1, etc... This is equivalent to adding
- the special value to the set of possibles values of a given type.
+ the special value to the set of possible values of a given type.
On modern languages, this can be modeled with a discriminated
union of T and something else such as a trivial POD or enum.
Discriminated unions are often called variants.
@@ -126,7 +126,7 @@ if ( p.second )
A discriminated union, which can be seen as a container which has an object of either type T or something else, has exactly the semantics required for a wrapper of optional values:
The other relevant feature of a pointer is that a pointer can have a null pointer value. This is a special value which is used to indicate that the pointer is not referring to any object at all. In other words, null pointer - values convey the notion of inexisting objects.
+ values convey the notion of inexistent objects.This meaning of the null pointer value allowed pointers to became a defacto standard for handling optional objects because all you have to do to refer to a value which you don't really have is to use a null pointer value of the appropriate type. Pointers have been used for decades -from the days of C APIs to modern C++ libraries- - to refer to optional (that is, possibly inexisting) objects; particularly + to refer to optional (that is, possibly inexistent) objects; particularly as optional arguments to a function, but also quite often as optional data members.
The possible presence of a null pointer value makes the operations that access the
pointee's value possibly undefined, therefore, expressions which use dereference
and access operators, such as: ( *p = 2 )
and ( p->foo())
,
- implicitely convey the notion of optionality, and this information is tied to
+ implicitly convey the notion of optionality, and this information is tied to
the syntax of the expressions. That is, the presence of operators * and -> tell by
themselves -without any additional context-, that the expression will be undefined unless
the implied pointee actually exist.
@@ -206,7 +206,7 @@ bool operator != ( optional<T> const& lhs, optional<T> const&
the form: if ( p != 0 ), or if ( p ) to be used to test for the existence of the pointee.
Such a defacto idiom for referring to optional objects can be formalized in the form of a
concept: the OptionalPointee concept.
-This concept captures the syntatic usage of operatos *, -> and conversion to bool to convey
+This concept captures the syntactic usage of operatos *, -> and conversion to bool to convey
the notion of optionality.
However, pointers are good to refer to optional objects, but not particularly good
to handle the optional objects in all other respects, such as initializing or moving/copying
@@ -223,7 +223,7 @@ them. The problem resides in the shallow-copy of pointer semantics: if you need
a builtin or small POD, this technique is very poor in terms of required resources.
Optional objects are essentially values so it is very convenient to be able to use automatic
storage and deep-copy semantics to manipulate optional values just as we do with ordinary
- values. Pointers do not have this semantics so are unapprorpiate for the initialization and
+ values. Pointers do not have this semantics, so are unapprorpiate for the initialization and
transport of optional values, yet are quite convenient for handling the access to the
possible undefined value because of the idiomatic aid present in the OptionalPointee
concept incarnated by pointers.
@@ -807,7 +807,8 @@ class Fred
optional<bool>
should be used with special caution and consideration.
First, it is functionally similar to a tristate boolean (false,maybe,true)
--such as boost::tribool-, except that in a tristate boolean, the maybe state
+-such as boost::tribool (not yet formally in boost)-,
+except that in a tristate boolean, the maybe state
represents a valid value, unlike the corresponding state
of an uninitialized optional<bool>.
It should be carefully considered if an optional bool instead of a tribool is really needed
type_with_alignment
(both from Type Traits).
It uses a separate boolean flag to indicate the initialization state.The implementation uses type_traits/alignement_of.hpp
-and type_traits/type_with_alignement.hpp
The implementation uses type_traits/alignment_of.hpp
+and type_traits/type_with_alignment.hpp
It has been tested on bcc5.5.1, vc6.0 and gcc2.95.2
type_traits/type_with_alignement.hpp
Post-formal review:
-William Kempf carrefully considered the originally proposed interface +
William Kempf carefully considered the originally proposed interface and suggested the new interface which is currently used. He also started and fueled the discussion about the analogy optional<>/smart pointer and about relational operators.
+ + + +Automatic redirection failed, please go to +doc/optional.html. + + \ No newline at end of file
diff --git a/index.html b/index.html new file mode 100644 index 0000000..cac816c --- /dev/null +++ b/index.html @@ -0,0 +1,9 @@ + +