<p>Although I'm doubtful, I'm curious as to whether it's possible to extract primitive-type template parameters from an existing type, perhaps using RTTI.</p>

<p>For example:</p>

<pre><code>typedef std::bitset&lt;16&gt; WordSet;
</code></pre>

<p>Would it be possible to extract the number 16 in the above code without hard-coding it elsewhere? Compiler specific implementations are welcome, though I'm particularly interested in <code>g++</code>.</p>

In the case of
```
std::bitset
```
, you can just use the
```
size()
```
member function:
```
```
size_t sz = oh_my_word.size();  // sz is now 16
```
```
In the general case, you can define a member function which returns the size in a similar manner:
```
```
template <int N>
class Foo
{
public:
  int size() const { return N; }
};
```
```