<div class="gmail_quote">On Mon, Aug 31, 2009 at 7:47 PM, Ryan McConnehey <span dir="ltr">&lt;<a href="mailto:mccorywork@gmail.com">mccorywork@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have a mpl::map as follows, with a template parameter of a passed in type and a template parameter of &quot;supported_type&quot; that is a class.<br>
<br>
using boost::mpl;<br>
enum { value = 1 + supported_type::value };<br>
typedef typename insert&lt;typename supported_type::type_map, pair&lt;T, int_&lt;value&gt; &gt; &gt;::type  type_map;<br>
<br>
I&#39;m trying to create a function that searches the map for a given type and returns a numeric value if it&#39;s found or -1 if it&#39;s not found.<br>
<br>
template &lt;typename S&gt;  int typeValue(void)  {<br>
 return at&lt; type_map, S, int_&lt;-1&gt; &gt;::type::value;<br>
}<br>
<br>
The documentation says I can specify a default value for &quot;at&quot; that is returned if the given key isn&#39;t found.  The compiler, though, says that I&#39;ve provided too many arguments.  Have I called &quot;at&quot; incorrectly?  Is the documentation incorrect?  Is the fault with the compiler (VS 2005)?<br>
<font color="#888888">
<br>
Ryan<br>
</font></blockquote></div><br>I&#39;ve created a work around using the boost::enable_if and boost::disable_if  that provides the functionality I need.  I would prefer to use the mpl::at with the default argument if I can.  If someone could help me I&#39;d appreciate it. <br>
<br>template &lt;typename S&gt; typename boost::enable_if&lt; boost::mpl::has_key&lt; type_map, S &gt;, int &gt;::type typeValue(void)  {<br>  return boost::mpl::at&lt; type_map, S &gt;::type::value;<br>}<br><br> template &lt;typename S&gt; typename boost::disable_if&lt; boost::mpl::has_key&lt; type_map, S &gt;, int &gt;::type typeValue(void)  {<br>
  return -1;<br> }<br><br>Ryan<br><br>

