|
From: Foster B. <fos...@us...> - 2005-04-18 21:15:56
|
Update of /cvsroot/adobe-source/sandbox/visual_refactor/adobe/documentation/sources/asl/concepts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27679/adobe/documentation/sources/asl/concepts Added Files: concept_assignable.dox concept_convertible_to_bool.dox concept_convertible_to_function.dox concept_convertible_to_range.dox concept_defaultconstructible.dox concept_equalitycomparable.dox concept_lessthancomparable.dox concept_regular_type.dox concept_transform_function.dox defgroup_concepts.dox Log Message: SO SORRY for the large qty of emails -- creating a branch for Adobe Begin refactoring. --- NEW FILE: defgroup_concepts.dox --- /*! \defgroup asl_concepts Concepts \ingroup asl_home */ --- NEW FILE: concept_transform_function.dox --- /*************************************************************************************************/ /* ADOBE CONFIDENTIAL ___________________ Copyright 2003 - 2003 Adobe Systems Incorporated All Rights Reserved. NOTICE: All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Adobe Systems Incorporated. */ /*************************************************************************************************/ /*! \defgroup concept_transform_function TransformFunction \ingroup asl_concepts \description A transformation (or transform) function is simply a Unary Function without side effects. That is, the use of the Unary Function does not change the state of the function object. For some algorithms it is required that the transform function return a writable result - in this case it must return a reference. \refinement_of - UnaryFunction \associated_types \notation <table> <tr> <td valign="top"><code>F</code></td> <td valign="top">A type that is a model of TransformFunction</td> </tr> <tr> <td valign="top"><code>X</code></td> <td valign="top">Argument type of F</td> </tr> <tr> <td valign="top"><code>Result</code></td> <td valign="top">Result type of F</td> </tr> <tr> <td valign="top"><code>f</code></td> <td valign="top">Object of type <code>F</code></td> </tr> <tr> <td valign="top"><code>x</code></td> <td valign="top">Object of type <code>X</code></td> </tr> </table> \definitions \valid_expressions \expression_semantics \complexity \invariants - The expression <code>f(x)</code> is <i>not</i> permitted to change <code>f</code>'s state. \models \notes \see_also \example Transform functions are typically used for the conversion of one type to another. An example: transforming a 3-space point into a 2-space point through a projection matrix; the projection matrix is the transform function, and its use does not modify the matrix. \example Another use of transform functions is to obtain an ordinal value for a complex data type. An example: Using a single member variable as the ordinal value for a class with several member variables, and sorting a vector of instances based on this ordinal value. The transformation only obtains the ordinal value and is not modified in any way. */ --- NEW FILE: concept_equalitycomparable.dox --- /*************************************************************************************************/ /* ADOBE CONFIDENTIAL ___________________ Copyright 2003 - 2003 Adobe Systems Incorporated All Rights Reserved. NOTICE: All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Adobe Systems Incorporated. */ /*************************************************************************************************/ /*! \defgroup stldoc_EqualityComparable EqualityComparable \ingroup asl_concepts \description A type is EqualityComparable if objects of that type can be compared for equality using <code>operator==</code>, and if <code>operator==</code> is an equivalence relation. \refinement_of \associated_types \notation <table> <tr> <td valign="top"><code>X</code></td> <td valign="top">A type that is a model of EqualityComparable</td> </tr> <tr> <td valign="top"><code>x</code>, <code>y</code>, <code>z</code></td> <td valign="top">Object of type <code>X</code></td> </tr> </table> \definitions \valid_expressions <table border> <tr> <th>Name</th><th>Expression</th><th>Type requirements</th><th>Return type</th> </tr> <tr> <td valign="top">Equality</td> <td valign="top"><code>x == y</code></td> <td valign="top"> </td> <td valign="top">Convertible to <code>bool</code></td> </tr> <tr> <td valign="top">Inequality</td> <td valign="top"><code>x != y</code></td> <td valign="top"> </td> <td valign="top">Convertible to <code>bool</code></td> </tr> </table> \expression_semantics <table border> <tr> <th>Name</th><th>Expression</th><th>Precondition</th><th>Semantics</th><th>Postcondition</th> </tr> <tr> <td valign="top">Equality</td> <td valign="top"><code>x == y</code></td> <td valign="top"><code>x</code> and <code>y</code> are in the domain of <code>==</code></td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top">Inequality</td> <td valign="top"><code>x != y</code></td> <td valign="top"><code>x</code> and <code>y</code> are in the domain of <code>==</code></td> <td valign="top">Equivalent to <code>!(x == y)</code></td> <td valign="top"> </td> </tr> </table> \complexity \invariants <table border> <tr> <td valign="top">Identity</td> <td valign="top"><code>&x == &y</code> implies <code>x</code> == <code>y</code></td> </tr> <tr> <td valign="top">Reflexivity</td> <td valign="top"><code>x == x</code></td> </tr> <tr> <td valign="top">Symmetry</td> <td valign="top"><code>x == y</code> implies <code>y == x</code></td> </tr> <tr> <td valign="top">Transitivity</td> <td valign="top"><code>x == y</code> and <code>y == z</code> implies <code>x == z</code></td> </tr> </table> \models - int - <code>std::vector<T></code> \notes \see_also - \ref stldoc_LessThanComparable */ --- NEW FILE: concept_convertible_to_bool.dox --- /*************************************************************************************************/ /* ADOBE CONFIDENTIAL ___________________ Copyright 2003 - 2003 Adobe Systems Incorporated All Rights Reserved. NOTICE: All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Adobe Systems Incorporated. */ /*************************************************************************************************/ /*! \defgroup concept_convertible_to_bool ConvertibleToBool \ingroup asl_concepts \description A type is ConvertibleToBool if it can be implicitly converted to a <code>boolean</code> value. \refinement_of \associated_types \notation <table> <tr> <td valign="top"><code>X</code></td> <td valign="top">A type that is a model of ConvertibleToBool</td> </tr> <tr> <td valign="top"><code>x</code></td> <td valign="top">Object of type <code>X</code></td> </tr> <tr> <td valign="top"><code>b</code></td> <td valign="top">Object of type <code>bool</code></td> </tr> </table> \definitions \valid_expressions <table border> <tr> <th>Name</th><th>Expression</th><th>Type requirements</th><th>Return type</th> </tr> <tr> <td valign="top">ConvertibleToBool</td> <td valign="top"><code>bool b = x;</code></td> <td valign="top"> </td> <td valign="top">bool</td> </tr> <tr> <td valign="top">ConvertibleToBool</td> <td valign="top"><code>if (x)</code><br>-or-<br><code>if (!x)</code></td> <td valign="top"> </td> <td valign="top"> </td> </tr> </table> \expression_semantics <table border> <tr> <th>Name</th><th>Expression</th><th>Precondition</th><th>Semantics</th><th>Postcondition</th> </tr> <tr> <td valign="top">ConvertibleToBool</td> <td valign="top"><code>bool b = x;</code></td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top">ConvertibleToBool</td> <td valign="top"><code>if (x)</code><br>-or-<br><code>if (!x)</code></td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> </table> \complexity \invariants \models - a pointer - adobe::name_t \notes \see_also */ --- NEW FILE: concept_lessthancomparable.dox --- /*************************************************************************************************/ /* ADOBE CONFIDENTIAL ___________________ Copyright 2003 - 2003 Adobe Systems Incorporated All Rights Reserved. NOTICE: All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Adobe Systems Incorporated. */ /*************************************************************************************************/ /*! \defgroup stldoc_LessThanComparable LessThanComparable \ingroup asl_concepts \description A type is LessThanComparable if it is ordered: it must be possible to compare two objects of that type using <code>operator<</code>, and <code>operator<</code> must be a partial ordering. \refinement_of \associated_types \notation <table> <tr> <td valign="top"><code>X</code></td> <td valign="top">A type that is a model of LessThanComparable</td> </tr> <tr> <td valign="top"><code>x</code>, <code>y</code>, <code>z</code></td> <td valign="top">Object of type <code>X</code></td> </tr> </table> \definitions Consider the relation <code>!(x < y) && !(y < x)</code>. If this relation is transitive (that is, if <code>!(x < y) && !(y < x) && !(y < z) && !(z < y)</code> implies <code>!(x < z) && !(z < x)</code>), then it satisfies the mathematical definition of an equivalence relation. In this case, <code>operator<</code> is a <i>strict weak ordering</i>. \par If <code>operator<</code> is a strict weak ordering, and if each equivalence class has only a single element, then <code>operator<</code> is a <i>total ordering</i>. \valid_expressions <table border> <tr> <th>Name</th><th>Expression</th><th>Type requirements</th><th>Return type</th> </tr> <tr> <td valign="top">Less</td> <td valign="top"><code>x < y</code></td> <td valign="top"> </td> <td valign="top">Convertible to <code>bool</code></td> </tr> <tr> <td valign="top">Greater</td> <td valign="top"><code>x > y</code></td> <td valign="top"> </td> <td valign="top">Convertible to <code>bool</code></td> </tr> <tr> <td valign="top">Less or equal</td> <td valign="top"><code>x <= y</code></td> <td valign="top"> </td> <td valign="top">Convertible to <code>bool</code></td> </tr> <tr> <td valign="top">Greater or equal</td> <td valign="top"><code>x >= y</code></td> <td valign="top"> </td> <td valign="top">Convertible to <code>bool</code></td> </tr> </table> \expression_semantics <table border> <tr> <th>Name</th><th>Expression</th><th>Precondition</th><th>Semantics</th><th>Postcondition</th> </tr> <tr> <td valign="top">Less</td> <td valign="top"><code>x < y</code></td> <td valign="top"><code>x</code> and <code>y</code> are in the domain of <code><</code></td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top">Greater</td> <td valign="top"><code>x > y</code></td> <td valign="top"><code>x</code> and <code>y</code> are in the domain of <code><</code></td> <td valign="top">Equivalent to <code>y < x</code> <A href="#1">[1]</A></td> <td valign="top"> </td> </tr> <tr> <td valign="top">Less or equal</td> <td valign="top"><code>x <= y</code></td> <td valign="top"><code>x</code> and <code>y</code> are in the domain of <code><</code></td> <td valign="top">Equivalent to <code>!(y < x)</code> <A href="#1">[1]</A></td> <td valign="top"> </td> </tr> <tr> <td valign="top">Greater or equal</td> <td valign="top"><code>x >= y</code></td> <td valign="top"><code>x</code> and <code>y</code> are in the domain of <code><</code></td> <td valign="top">Equivalent to <code>!(x < y)</code> <A href="#1">[1]</A></td> <td valign="top"> </td> </tr> </table> \complexity \invariants <table border> <tr> <td valign="top">Irreflexivity</td> <td valign="top"><code>x < x</code> must be false.</td> </tr> <tr> <td valign="top">Antisymmetry</td> <td valign="top"><code>x < y</code> implies !(y < x) <A href="#2">[2]</A></td> </tr> <tr> <td valign="top">Transitivity</td> <td valign="top"><code>x < y</code> and <code>y < z</code> implies <code>x < z</code> <A href="#3">[3]</A></td> </tr> </table> \models - int - adobe::name_t \notes <A name="1">[1]</A> Only <code>operator<</code> is fundamental; the other inequality operators are essentially syntactic sugar. \par <A name="2">[2]</A> Antisymmetry is a theorem, not an axiom: it follows from irreflexivity and transitivity. \par <A name="3">[3]</A> Because of irreflexivity and transitivity, <code>operator<</code> always satisfies the definition of a <i>partial ordering</i>. The definition of a <i>strict weak ordering</i> is stricter, and the definition of a <i>total ordering</i> is stricter still. \see_also - \ref stldoc_EqualityComparable */ --- NEW FILE: concept_convertible_to_range.dox --- /*************************************************************************************************/ /* ADOBE CONFIDENTIAL ___________________ Copyright 2002 - 2004 Adobe Systems Incorporated All Rights Reserved. NOTICE: All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Adobe Systems Incorporated. */ /*! \defgroup concept_convertible_to_range ConvertibleToRange \ingroup asl_concepts \description ConvertibleToRange denotes a sequence of the form: <code>[begin, end)</code>. The elements of the range are the beginning element to the element before the end element. The following are examples of ranges: - A <i>container</i>, denotes a range <code>[container.begin(), container.end())</code> - An <i>array</i>, denotes a range <code>[array[0], array[sizeof(array)/sizeof(array[0])])</code> - An <i>std::pair</i> of <i>iterators</i> denotes a range <code>[pair.first, pair.last)</code> \refinement_of \associated_types \notation <table> <tr> <td valign="top"><code>X</code></td> <td valign="top">A type that is a model of ConvertibleToRange</td> </tr> <tr> <td valign="top"><code>x</code></td> <td valign="top">Object of type <code>X</code></td> </tr> <tr> <td valign="top"><code>I</code></td> <td valign="top">A type for iterating over objects of type <code>X</code></td> </tr> <tr> <td valign="top"><code>p</code>, <code>q</code></td> <td valign="top">Objects of type <code>I</code></td> </tr> </table> \definitions \subpar Valid Iterator \c p is a <i>valid iterator</i> in \c x if it is a valid (nonsingular) iterator that is reachable from \c adobe::begin(x). \subpar Valid Range <code>[p, q)</code> is a <i>valid range</i> in \c x if \c p and \c q are valid iterators in \c x and if \c q is reachable from \c p. \valid_expressions \expression_semantics \complexity \invariants \subpar Range Size \c adobe::size(x) is equal to the distance from \c adobe::begin(x) to \c adobe::end(x). \subpar Completeness An algorithm that iterates through the range <code>[adobe::begin(x), adobe::end(x))</code> will pass through every element of \c x. <A href="#1">[1]</A> \notes <A name="1">[1]</A> The order in which the elements appear in any range is unspecified, even between two iterations where the range has had no intervening mutative operations. */ --- NEW FILE: concept_assignable.dox --- /*************************************************************************************************/ /* ADOBE CONFIDENTIAL ___________________ Copyright 2003 - 2003 Adobe Systems Incorporated All Rights Reserved. NOTICE: All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Adobe Systems Incorporated. */ /*************************************************************************************************/ /*! \defgroup stldoc_Assignable Assignable \ingroup asl_concepts \description A type is Assignable if it is possible to copy objects of that type and to assign values to variables. \refinement_of \associated_types \notation <table> <tr> <td valign="top"><code>X</code></td> <td valign="top">A type that is a model of Assignable</td> </tr> <tr> <td valign="top"><code>x</code>, <code>y</code></td> <td valign="top">Object of type <code>X</code></td> </tr> </table> \definitions \valid_expressions <table border> <tr> <th>Name</th><th>Expression</th><th>Type requirements</th><th>Return type</th> </tr> <tr> <td valign="top">Copy constructor</td> <td valign="top"><code>X(x)</code></td> <td valign="top"> </td> <td valign="top"><code>X</code></td> </tr> <tr> <td valign="top">Copy constructor</td> <td valign="top"> <pre>X x(y); X x = y; </pre> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top">Assignment</td> <td valign="top"><code>x = y</code> <A href="#1">[1]</A></td> <td valign="top"> </td> <td valign="top"><code>X&</code></td> </tr> <tr> <td valign="top">Swap</td> <td valign="top"><code>adobe::swap(x,y)</code></td> <td valign="top"> </td> <td valign="top"><code>void</code></td> </tr> </table> \expression_semantics <table border> <tr> <th>Name</th><th>Expression</th><th>Precondition</th><th>Semantics</th><th>Postcondition</th> </tr> <tr> <td valign="top">Copy constructor</td> <td valign="top"><code>X(x)</code></td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"><code>X(x)</code> is a copy of <code>x</code> <A href="#2">[2]</A></td> </tr> <tr> <td valign="top">Copy constructor</td> <td valign="top"><code>X(x)</code></td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"><code>X(x)</code> is a copy of <code>x</code> <A href="#2">[2]</A></td> </tr> <tr> <td valign="top">Copy constructor</td> <td valign="top"> <pre>X x(y); X x = y; </pre> </td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"><code>x</code> is a copy of <code>y</code> <A href="#2">[2]</A></td> </tr> <tr> <td valign="top">Assignment</td> <td valign="top"><code>x</code> = <code>y</code> <A href="#1">[1]</A></td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"><code>x</code> is a copy of <code>y</code> <A href="#2">[2]</A></td> </tr> <tr> <td valign="top">Swap</td> <td valign="top"><code>adobe::swap(x,y)</code><A href="#3">[3]</A></td> <td valign="top"> </td> <td valign="top"> Equivalent to <pre>{ X tmp = x; x = y; y = tmp; } </pre> </td> <td valign="top"> </td> </tr> </table> \complexity \invariants \models - int \notes <A name="1">[1]</A> One implication of this requirement is that a <code>const</code> type is not Assignable. For example, <code>const int</code> is not Assignable: if <code>x</code> is declared to be of type <code>const int</code>, then <code>x = 7</code> is illegal. Similarly, the type <code>pair<const int, int></code> is not Assignable. \par <A name="2">[2]</A> The reason this says "<code>x</code> is a copy of <code>y</code>", rather than "<code>x == y</code>", is that <code>operator==</code> is not necessarily defined: equality is not a requirement of Assignable. If the type <code>X</code> is \ref stldoc_EqualityComparable as well as Assignable, then a copy of <code>x</code> should compare equal to <code>x</code>. \par <A name="3">[3]</A> \c adobe::swap will not throw an exception for an assignable type. For types with remote parts, \c adobe::swap must be specialized to swap the remote parts. <!--Please see the documentation on adobe::swap for more information.--> \par <A name="4">[4]</A> It is assumed that adobe::swap() will not throw an exception. Items with remote parts much specialize swap as described in \ref swap. \see_also - \ref stldoc_DefaultConstructible - \ref stldoc_EqualityComparable */ --- NEW FILE: concept_regular_type.dox --- /*************************************************************************************************/ /* ADOBE CONFIDENTIAL ___________________ Copyright 2003 - 2003 Adobe Systems Incorporated All Rights Reserved. NOTICE: All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers, if any. the intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Adobe Systems Incorporated. */ /*************************************************************************************************/ /*! \defgroup concept_regular_type RegularType \ingroup asl_concepts \description At the most fundamental level, RegularType is any type that "behaves like <code>int</code>". That is to say that when you copy a RegularType, it copies all the parts, both local and remote. This is also known as a Value because when you copy a Value you are copying the entirety of the Value, not just a pointer (or some other type of reference) to it. \refinement_of - \ref stldoc_DefaultConstructible - \ref stldoc_Assignable - \ref stldoc_EqualityComparable \notation \valid_expressions All expressions that match the above concepts are valid. \expression_semantics All expression semantics that match the above concepts are valid. \models - adobe::name_t - adobe::copy_on_write \notes \see_also - Alex Stepanov's paper on the <a href="http://www.stepanovpapers.com/DeSt98.pdf">concept of regular types</a>. */ --- NEW FILE: concept_defaultconstructible.dox --- /*************************************************************************************************/ /* ADOBE CONFIDENTIAL ___________________ Copyright 2003 - 2003 Adobe Systems Incorporated All Rights Reserved. NOTICE: All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Adobe Systems Incorporated. */ /*************************************************************************************************/ /*! \defgroup stldoc_DefaultConstructible DefaultConstructible \ingroup asl_concepts \description A type is DefaultConstructible if it has a default constructor, that is, if it is possible to construct an object of that type without initializing the object to any particular value. \refinement_of \associated_types \notation <table> <tr> <td valign="top"><code>X</code></td> <td valign="top">A type that is a model of DefaultConstructible</td> </tr> <tr> <td valign="top"><code>x</code></td> <td valign="top">An object of type <code>X</code></td> </tr> </table> \definitions \valid_expressions <table border> <tr> <th>Name</th><th>Expression</th><th>Type requirements</th><th>Return type</th> </tr> <tr> <td valign="top">Default constructor</td> <td valign="top"><code>X()</code></td> <td valign="top"> </td> <td valign="top"><code>X</code></td> </tr> <tr> <td valign="top">Default constructor</td> <td valign="top"><code>X x;</code> <A href="#1">[1]</A></td> <td valign="top"> </td> <td valign="top"> </td> </tr> </table> \expression_semantics <table border> <tr> <th>Name</th><th>Expression</th><th>Precondition</th><th>Semantics</th><th>Postcondition</th> </tr> <tr> <td valign="top">Default constructor</td> <td valign="top"><code>X()</code></td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top">Default constructor</td> <td valign="top"><code>X x;</code></td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> </table> \complexity \models - int - adobe::name_t - adobe::copy_on_write \notes <A name="1">[1]</A> The form <code>X x = X()</code> is not guaranteed to be a valid expression, because it uses a copy constructor. A type that is DefaultConstructible is not necessarily \ref stldoc_Assignable \see_also - \ref stldoc_Assignable */ --- NEW FILE: concept_convertible_to_function.dox --- /*************************************************************************************************/ /* ADOBE CONFIDENTIAL ___________________ Copyright 2003 - 2003 Adobe Systems Incorporated All Rights Reserved. NOTICE: All information contained herein is, and remains the property of Adobe Systems Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Adobe Systems Incorporated. */ /*************************************************************************************************/ /*! \defgroup concept_convertible_to_function ConvertibleToFunction \ingroup asl_concepts \description A ConvertibleToFunction is simply something which can be invoked using function notation - or something that \c boost::bind can convert to a function. Specifically, a ConvertibleToFunction can be: - A pointer to a function - A pointer to a class or struct data member (argument is a pointer or a reference to a struct/class instance) - A pointer to a class or struct member function (first argument is a pointer or a reference to a struct/class instance; Member function arguments follow in order) - A \c boost::reference_wrapper to a ConvertibleToFunction - A function object Where functions are passed as template parameters in the Adobe Source Libraries, any ConvertibleToFunction may be used. The idea is that <code>boost::bind(x, ...);</code> is a valid expression where <code>...</code> are arguments to <code>x</code>. <code>x</code>, in this case, is ConvertibleToFunction. \refinement_of \associated_types \notation <table> <tr> <td valign="top"><code>F</code></td> <td valign="top">A type that is a model of ConvertibleToFunction</td> </tr> <tr> <td valign="top"><code>x1...xn</code></td> <td valign="top">An optional argument list for the type that is a model of ConvertibleToFunction</td> </tr> <tr> <td valign="top"><code>f</code></td> <td valign="top">Object of type <code>F</code></td> </tr> </table> \definitions \valid_expressions <table border> <tr> <th>Name</th><th>Expression</th><th>Type requirements</th><th>Return type</th> </tr> <tr> <td valign="top">Convertible</td> <td valign="top"><code>boost::bind(&f, x1...xn);</code></td> <td valign="top"> </td> <td valign="top">An invokable <code>boost::function</code> whose template argument is the function signature of <code>f</code></td> </tr> </table> \expression_semantics \complexity \invariants \models - Anything that is acceptable to <code>boost::bind</code>. \example Given a \c vector of structs... \par \code struct my_struct { bool value_m; } std::vector<my_struct> my_vector; // Code here to fill the vector with some bools... \endcode \par Writing the following would be an error: \par \code iter = std::find_if(my_vector.begin(), my_vector.end(), &my_struct::value_m); // Error! \endcode \par But because a pointer to a member is ConvertibleToFunction, and in this case the function meets the requirements of a predicate (that is, the accessing of \c value_m will return either \c true or \c false) we can write: \par \code iter = adobe::find_if(my_vector.begin(), my_vector.end(), &my_struct::value_m); // works! \endcode \par Further, because \c vector meets the requirements of a \ref concept_convertible_to_range, this can be shortened to: \par \code iter = adobe::find_if(my_vector, &my_struct::value_m); // also works! \endcode */ |