<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[templates und character types]]></title><description><![CDATA[<p>Ich hab eine klasse, mit einem character type als template argument<br />
(also char, wchar_t, u16char, u32char)</p>
<pre><code>template&lt;typename char_type&gt;
class MyClass{
  char_type c;
public:
  void setDefault(){
    c = 'a';
  }
};
</code></pre>
<p>und da ist auch schon das problem, egal welcher char_type es ist, ich will immer das gleiche zeichen speichern, aber will die funktion für jeden typ spezialisieren.<br />
ohne geht aber auch nicht, weil es bei wchar_t L'a' heißt, bei u16char u16'a' und so weiter... gibt es da eine einfachere methode?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/314382/templates-und-character-types</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 08:55:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/314382.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 28 Feb 2013 20:14:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to templates und character types on Thu, 28 Feb 2013 20:14:04 GMT]]></title><description><![CDATA[<p>Ich hab eine klasse, mit einem character type als template argument<br />
(also char, wchar_t, u16char, u32char)</p>
<pre><code>template&lt;typename char_type&gt;
class MyClass{
  char_type c;
public:
  void setDefault(){
    c = 'a';
  }
};
</code></pre>
<p>und da ist auch schon das problem, egal welcher char_type es ist, ich will immer das gleiche zeichen speichern, aber will die funktion für jeden typ spezialisieren.<br />
ohne geht aber auch nicht, weil es bei wchar_t L'a' heißt, bei u16char u16'a' und so weiter... gibt es da eine einfachere methode?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303066</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303066</guid><dc:creator><![CDATA[gamer8o4]]></dc:creator><pubDate>Thu, 28 Feb 2013 20:14:04 GMT</pubDate></item><item><title><![CDATA[Reply to templates und character types on Thu, 28 Feb 2013 20:18:59 GMT]]></title><description><![CDATA[<p>Das ist das dritte mal, dass ich diese Frage lese...<br />
<a href="http://www.c-plusplus.net/forum/314145-full" rel="nofollow">http://www.c-plusplus.net/forum/314145-full</a><br />
Könnte jemand mal eine gute Antwort schreiben und sie in die FAQ stellen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303067</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303067</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Thu, 28 Feb 2013 20:18:59 GMT</pubDate></item><item><title><![CDATA[Reply to templates und character types on Thu, 28 Feb 2013 20:56:32 GMT]]></title><description><![CDATA[<pre><code>template&lt;typename char_type&gt;
struct MyClassCharTraits;

template&lt;typename char_type&gt;
struct MyClassCharTraits&lt;char&gt;
{
  static const char default_value = 'a';
};

template&lt;typename char_type&gt;
struct MyClassCharTraits&lt;wchar_t&gt;
{
  static const wchar_t default_value = L'a';
};

...

template&lt;typename char_type&gt;
class MyClass
{
private:
  char_type c;
public:
  void setDefault()
  {
    c = MyClassCharTraits&lt;char_type&gt;::default_value;
  }
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2303075</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303075</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Thu, 28 Feb 2013 20:56:32 GMT</pubDate></item><item><title><![CDATA[Reply to templates und character types on Fri, 01 Mar 2013 13:47:38 GMT]]></title><description><![CDATA[<p>danke, hat geklappt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2303319</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2303319</guid><dc:creator><![CDATA[gamer8o4]]></dc:creator><pubDate>Fri, 01 Mar 2013 13:47:38 GMT</pubDate></item></channel></rss>