JSP tricks to make templating easier?

As skaffman suggested, JSP 2.0 Tag Files are the bee’s knees. Let’s take your simple example. Put the following in WEB-INF/tags/wrapper.tag <%@tag description=”Simple Wrapper Tag” pageEncoding=”UTF-8″%> <html><body> <jsp:doBody/> </body></html> Now in your example.jsp page: <%@page contentType=”text/html” pageEncoding=”UTF-8″%> <%@taglib prefix=”t” tagdir=”/WEB-INF/tags” %> <t:wrapper> <h1>Welcome</h1> </t:wrapper> That does exactly what you think it does. So, lets expand … Read more

Why can’t the template argument be deduced when it is used as template parameter to another template?

That is non-deducible context. That is why the template argument cannot be deduced by the compiler. Just imagine if you might have specialized TMap as follows: template <> struct TMap<SomeType> { typedef std::map <double, double> Type; }; How would the compiler deduce the type SomeType, given that TMap<SomeType>::Type is std::map<double, double>? It cannot. It’s not … Read more

C++ template typedef

C++11 added alias declarations, which are generalization of typedef, allowing templates: template <size_t N> using Vector = Matrix<N, 1>; The type Vector<3> is equivalent to Matrix<3, 1>. In C++03, the closest approximation was: template <size_t N> struct Vector { typedef Matrix<N, 1> type; }; Here, the type Vector<3>::type is equivalent to Matrix<3, 1>.

C++11 does not deduce type when std::function or lambda functions are involved

The issue is on the nature of lambdas. They are function objects with a fixed set of properties according to the standard, but they are not a function. The standard determines that lambdas can be converted into std::function<> with the exact types of arguments and, if they have no state, function pointers. But that does … Read more

How does `void_t` work

1. Primary Class Template When you write has_member<A>::value, the compiler looks up the name has_member and finds the primary class template, that is, this declaration: template< class , class = void > struct has_member; (In the OP, that’s written as a definition.) The template argument list <A> is compared to the template parameter list of … Read more

Why do I get “unresolved external symbol” errors when using templates? [duplicate]

Templated classes and functions are not instantiated until they are used, typically in a separate .cpp file (e.g. the program source). When the template is used, the compiler needs the full code for that function to be able to build the correct function with the appropriate type. However, in this case the code for that … Read more

tech