<div class="gmail_quote">2009/5/6 Ryan McConnehey <span dir="ltr"><<a href="mailto:mccorywork@gmail.com">mccorywork@gmail.com</a>></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'm currently trying to fortify my class api by "make interfaces easy to use correctly and hard to use incorrectly". �I have a class as follows.<br> <br> class api<br> {<br> � api(ConfigName const& configName_, PathName const& 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<typename S><br> struct ParameterValue<br> {<br> � ParameterValue(S value_) : value(value_) {}<br> � S value<br> };<br> <br> typedef ParameterValue<std::string> � ConfigName;<br> typedef ParameterValue<std::string> � PathName;<br> <br> I realized later that this method doesn't prevent the swapping of a ConfigName with a PathName parameter. �Since both parameters are typedef to the same "type" of ParameterValue they're interchangeable. �Is there a boost class, library or C++ idiom that would provide what I'm looking for? �Since I'm going to be using this concept for other classes I build, I'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'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<typename S, <b>int N</b>></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<std::string, <b>0</b>> � ConfigName;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> typedef ParameterValue<std::string, <b>1</b>> � PathName;</span><br><br>Roman Perepelitsa.<br>