A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2Ftemplate%2FTemplate_specialization</id>
		<title>C++ Tutorial/template/Template specialization - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2Ftemplate%2FTemplate_specialization"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/template/Template_specialization&amp;action=history"/>
		<updated>2026-04-11T02:24:06Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/template/Template_specialization&amp;diff=2601&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/template/Template_specialization&amp;diff=2601&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:17Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/template/Template_specialization&amp;diff=2602&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/template/Template_specialization&amp;diff=2602&amp;oldid=prev"/>
				<updated>2010-05-25T10:30:04Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Partial specialization as end criteria==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;/* The following code example is taken from the book&lt;br /&gt;
 * &amp;quot;C++ Templates - The Complete Guide&amp;quot;&lt;br /&gt;
 * by David Vandevoorde and Nicolai M. Josuttis, Addison-Wesley, 2002&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright David Vandevoorde and Nicolai M. Josuttis 2002.&lt;br /&gt;
 * Permission to copy, use, modify, sell and distribute this software&lt;br /&gt;
 * is granted provided this copyright notice appears in all copies.&lt;br /&gt;
 * This software is provided &amp;quot;as is&amp;quot; without express or implied&lt;br /&gt;
 * warranty, and with no claim as to its suitability for any purpose.&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// primary template&lt;br /&gt;
template &amp;lt;int DIM, typename T&amp;gt;&lt;br /&gt;
class DotProduct {&lt;br /&gt;
  public:&lt;br /&gt;
    static T result (T* a, T* b) {&lt;br /&gt;
        return *a * *b  +  DotProduct&amp;lt;DIM-1,T&amp;gt;::result(a+1,b+1);&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
// partial specialization as end criteria&lt;br /&gt;
template &amp;lt;typename T&amp;gt;&lt;br /&gt;
class DotProduct&amp;lt;1,T&amp;gt; {&lt;br /&gt;
  public:&lt;br /&gt;
    static T result (T* a, T* b) {&lt;br /&gt;
        return *a * *b;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
// convenience function&lt;br /&gt;
template &amp;lt;int DIM, typename T&amp;gt;&lt;br /&gt;
inline T dot_product (T* a, T* b)&lt;br /&gt;
{&lt;br /&gt;
    return DotProduct&amp;lt;DIM,T&amp;gt;::result(a,b);&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int a[3] = { 1, 2, 3};&lt;br /&gt;
    int b[3] = { 5, 6, 7};&lt;br /&gt;
              &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
              &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;dot_product&amp;lt;3&amp;gt;(a,b) = 38&lt;br /&gt;
dot_product&amp;lt;3&amp;gt;(a,a) = 14&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Primary template to compute 3 to the Nth and full specialization to end the recursion==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;/* The following code example is taken from the book&lt;br /&gt;
 * &amp;quot;C++ Templates - The Complete Guide&amp;quot;&lt;br /&gt;
 * by David Vandevoorde and Nicolai M. Josuttis, Addison-Wesley, 2002&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright David Vandevoorde and Nicolai M. Josuttis 2002.&lt;br /&gt;
 * Permission to copy, use, modify, sell and distribute this software&lt;br /&gt;
 * is granted provided this copyright notice appears in all copies.&lt;br /&gt;
 * This software is provided &amp;quot;as is&amp;quot; without express or implied&lt;br /&gt;
 * warranty, and with no claim as to its suitability for any purpose.&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// primary template to compute 3 to the Nth&lt;br /&gt;
template&amp;lt;int N&amp;gt;&lt;br /&gt;
class Pow3 {&lt;br /&gt;
  public:&lt;br /&gt;
    enum { result = 3 * Pow3&amp;lt;N-1&amp;gt;::result };&lt;br /&gt;
};&lt;br /&gt;
// full specialization to end the recursion&lt;br /&gt;
template&amp;lt;&amp;gt;&lt;br /&gt;
class Pow3&amp;lt;0&amp;gt; {&lt;br /&gt;
  public:&lt;br /&gt;
    enum { result = 1 };&lt;br /&gt;
};&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Pow3&amp;lt;7&amp;gt;::result = &amp;quot; &amp;lt;&amp;lt; Pow3&amp;lt;7&amp;gt;::result&lt;br /&gt;
              &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Pow3&amp;lt;7&amp;gt;::result = 2187&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Template specialization==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream.h&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class MyClass {&lt;br /&gt;
    T value1, value2;&lt;br /&gt;
  public:&lt;br /&gt;
    MyClass (T first, T second)&lt;br /&gt;
      {value1=first; value2=second;}&lt;br /&gt;
    T module () {return 0;}&lt;br /&gt;
};&lt;br /&gt;
template &amp;lt;&amp;gt;&lt;br /&gt;
class MyClass &amp;lt;int&amp;gt; {&lt;br /&gt;
    int value1, value2;&lt;br /&gt;
  public:&lt;br /&gt;
    MyClass (int first, int second){&lt;br /&gt;
        value1 = first; &lt;br /&gt;
        value2 = second;&lt;br /&gt;
    }&lt;br /&gt;
    int module (){&lt;br /&gt;
        return value1value2;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
int main () {&lt;br /&gt;
  MyClass &amp;lt;int&amp;gt; myints (100,75);&lt;br /&gt;
  MyClass &amp;lt;float&amp;gt; myfloats (100.0,75.0);&lt;br /&gt;
  cout &amp;lt;&amp;lt; myints.module() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; myfloats.module() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;25&lt;br /&gt;
0&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>