<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
> Date: Sat, 2 Jan 2010 11:42:34 -0600<br>> From: rodney<br>> On a separate issue, one of the things that the C++ template facility really<br>> botched badly is that instantiations not only can be, but must be, anonymous.<br><br><br>Can be, but not must be.<br><br><br>for types:<br>  typedef vector<int> vi_t.<br><br><br>for functions, well, usually the parameters are deduced and you<br>don't have to say them:<br><br><br>template <typename T> T max(const T& a, const T& b)<br>{<br>  return (a > b ? a : b);<br>}<br><br><br>max(1, 2);<br><br><br>If you have something like:<br><br><br>template <typename T> T* New() { return new T(); }<br><br>then you do have to say New<Foo>().<br>You could do something onerous like:<br>Foo* (*const NewFoo)() = New<T>;<br><br><br>There is a new feature that might enable:<br><br><br>const auto NewFoo = New<T>;<br>
<br><br>but really, deduction of function template parameters is a very good thing,<br>no need to fight it, and making the parameters explicit<br>for some scenarios is not so bad.<br><br><br>There are some very confusing things about templates:<br>  How much can be checked without instantiation?<br>  Which names are bound at template definition vs. instantiation?<br>  Can "template metaprogramming" be done in a more direct way instead<br>    of seemingly just being an accident?<br><br><br>And (with reverse spin) there are some very powerful things you can do with templates:<br>   template meta programming :) <br>   very good levels of inlining where otherwise you'd have little choice but to use<br>     function pointers and have poor efficiency (though, not that you can't <br>     implement things easily enough and have them at least work without templates)<br>   not sure the term, but have you seen how in C++ you can write:<br>     a = b + c + d + e;<br><br><br>where the types involves are vectors/matrices and it compiles down<br>to have no temporary vectors/matrices.<br><br><br> - Jay<br>                                        </body>
</html>