<div class="gmail_quote">2009/5/6 Ryan McConnehey <span dir="ltr">&lt;<a href="mailto:mccorywork@gmail.com">mccorywork@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I&#39;m currently trying to fortify my class api by &quot;make interfaces easy to use correctly and hard to use incorrectly&quot;. �I have a class as follows.<br>
<br>
class api<br>
{<br>
 � api(ConfigName const&amp; configName_, PathName const&amp; pathName_)<br>
 � : m_ConfigName(configName_.value)<br>
 � , m_PathName(pathName_.value)<br>
 � {}<br>
<br>
 � std::string � m_ConfigName;<br>
 � std::string � m_PathName;<br>
};<br>
<br>
Both ConfigName and PathName are typedef to a template structure as follows.<br>
<br>
template&lt;typename S&gt;<br>
struct ParameterValue<br>
{<br>
 � ParameterValue(S value_) : value(value_) {}<br>
 � S value<br>
};<br>
<br>
typedef ParameterValue&lt;std::string&gt; � ConfigName;<br>
typedef ParameterValue&lt;std::string&gt; � PathName;<br>
<br>
I realized later that this method doesn&#39;t prevent the swapping of a ConfigName with a PathName parameter. �Since both parameters are typedef to the same &quot;type&quot; of ParameterValue they&#39;re interchangeable. �Is there a boost class, library or C++ idiom that would provide what I&#39;m looking for? �Since I&#39;m going to be using this concept for other classes I build, I&#39;d like something that would easily create parameter classes to use but not be interchangeable with other classes of the same type. �I know that I could do this with a macro but I&#39;m leaving that for a last resort.<br>

<br>
Ryan<br></blockquote></div><br>Try this:<br><br><span style="font-family: courier new,monospace;">
template&lt;typename S, <b>int N</b>&gt;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
struct ParameterValue</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
{</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
 � ParameterValue(S value_) : value(value_) {}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
 � S value</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
};</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
typedef ParameterValue&lt;std::string, <b>0</b>&gt; � ConfigName;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
typedef ParameterValue&lt;std::string, <b>1</b>&gt; � PathName;</span><br><br>Roman Perepelitsa.<br>