More C++11 doc and test improvements

This commit is contained in:
William S Fulton 2014-03-10 18:55:57 +00:00
parent 3fb973644e
commit adc3cfeb57
2 changed files with 38 additions and 5 deletions

View File

@ -138,13 +138,13 @@ When either of these is used from a target language, a runtime call is made to o
<p>SWIG correctly parses the keywords <tt>extern template</tt>.
However, this template instantiation suppression in a translation unit has no relevance for SWIG.
However, this template instantiation suppression in a translation unit has no relevance outside of the C++ compiler and so is not used by SWIG.
SWIG only uses <tt>%template</tt> for instantiating and wrapping templates.</p>
<div class="code"><pre>
template class std::vector&lt;int&gt;; // C++03 explicit instantiation in C++
template class std::vector&lt;int&gt;; // C++03 explicit instantiation in C++
extern template class std::vector&lt;int&gt;; // C++11 explicit instantiation suppression in C++
%template(VectorInt) std::vector&lt;int&gt;; // SWIG instantiation
%template(VectorInt) std::vector&lt;int&gt;; // SWIG instantiation
</pre></div>
<H3><a name="CPlusPlus11_initializer_lists"></a>7.2.4 Initializer lists</H3>
@ -400,7 +400,8 @@ auto square(float a, float b) -&gt; decltype(a);
<p>
SWIG is able to handle constructor delegation, such as:
There are three parts to object construction improvement.
The first improvement is constructor delegation such as the following:
</p>
<div class="code"><pre>
@ -418,7 +419,13 @@ public:
</pre></div>
<p>
Constructor inheritance is parsed correctly, but the additional constructors are not currently added to the derived proxy class in the target language. Example is shown below:
where peer constructors can be called. SWIG handles this without any issue.
</p>
<p>
The second improvement is constructor inheritance via a <tt>using</tt> declaration.
This is parsed correctly, but the additional constructors are not currently added to the derived proxy class in the target language.
An example is shown below:
<!--
The extra constructors provided by the <tt>using</tt> syntax will add the appropriate constructors into the target language proxy derived classes.
In the example below a wrapper for the <tt>DerivedClass(int)</tt> is added to <tt>DerivedClass</tt>:
@ -437,6 +444,21 @@ class DerivedClass: public BaseClass {
};
</pre></div>
<p>
The final part is member initialization at the site of the declaration.
This kind of initialization is handled by SWIG.
</p>
<div class="code"><pre>
class SomeClass {
public:
SomeClass() {}
explicit SomeClass(int new_value) : value(new_value) {}
int value = 5;
};
</pre></div>
<H3><a name="CPlusPlus11_explicit_overrides_final"></a>Explicit overrides and final</H3>
<p>

View File

@ -4,6 +4,7 @@
%module cpp11_inheriting_constructors
%inline %{
// Delegating constructors
class BaseClass {
private:
int _val;
@ -11,8 +12,18 @@ public:
BaseClass(int iValue) { _val = iValue; }
};
// Constructor inheritance via using declaration
class DerivedClass: public BaseClass {
public:
using BaseClass::BaseClass; // Adds DerivedClass(int) constructor
};
// Member initialization at the site of the declaration
class SomeClass {
public:
SomeClass() {}
explicit SomeClass(int new_value) : value(new_value) {}
int value = 5;
};
%}