diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2013-02-02 01:15:28 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2013-02-02 20:03:10 +0000 |
commit | c8ff23de0c5fdc60a7a5335bcf937ac25a6a3d39 (patch) | |
tree | c36e3463ab3345dbf411c238e94a0b04a5b7de2c /Doc/Manual | |
parent | a043b55b69d4587a1bd95b934b85acb683e415e6 (diff) | |
download | swig-c8ff23de0c5fdc60a7a5335bcf937ac25a6a3d39.tar.gz |
Initialization list doc updates and new tests. Fix functions with default arguments that are initializer lists
Diffstat (limited to 'Doc/Manual')
-rw-r--r-- | Doc/Manual/Cpp0x.html | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/Doc/Manual/Cpp0x.html b/Doc/Manual/Cpp0x.html index aa8c41225..341cb3ce5 100644 --- a/Doc/Manual/Cpp0x.html +++ b/Doc/Manual/Cpp0x.html @@ -126,13 +126,14 @@ public: <H3><a name="Cpp0x_Initializer_lists"></a>7.2.4 Initializer lists</H3> -<p>Constructors using the std::initializer_list class are removed -from the wrapped class, because the only way to access such a -constructor is at compile time using the "= {}" assignment.</p> -<p>Users should add another constructor with specific arguments -filling the class members manually.</p> +<p> +Constructors using the std::initializer_list class are removed +from the wrapped class because the only way to access such a +constructor is at compile time using the initialization list syntax. +Initializer lists are very much a C++ construct and not very accessible from wrappers. +</p> -<p>For now, if a user wants to fill the class components like this:</p> +<p>For now, if you want to fill the class components like this:</p> <div class="code"><pre> class A { @@ -142,7 +143,7 @@ public: A a1 = {1,2,3,4}; </pre></div> -<p>You should add another constructor using the std::vector for example:</p> +<p>you could add another constructor using <tt>std::vector</tt> for example:</p> <div class="code"><pre> class A { @@ -153,11 +154,26 @@ public: A a1 = {1,2,3,4}; </pre></div> -<p>And call it from your target language, for example, in Python:</p> +<p>And then construct it from your target language, for example, in Python:</p> <div class="targetlang"><pre> >>> a2 = A( [1,2,3,4] ) </pre></div> +<p> +<tt>std::initializer_list</tt> is simply a container that can only be initialised at compile time. +As such it is possible to write typemaps for a target language container to map onto +<tt>std::initializer_list</tt>. However, this can only be done for a fixed number of elements ... +there is no way to construct an initializer list with a variable number of arguments at runtime. +This is not particularly flexible though outside of C++ static initialization, +hence the need to provide an alternative for use from a target language. +</p> + +<p> +Initializer lists can appear in any function or method, not just constructors. +SWIG only ignores the constructors as this is where they commonly occur. +Users are recommended to manually ignore any other methods using an initialization list with <tt>%ignore</tt>. +</p> + <H3><a name="Cpp0x_Uniform_initialization"></a>7.2.5 Uniform initialization</H3> |