Same template class with type/non-type parameters?

Given a template class myclass, is there a tricky way to allow this for the user :

myclass<void> x;
myclass<double> y;
myclass<42> z; // I do not expect the classic hack 
               // myclass<std::integral_constant<int, 42>>

because in certain context, it can make sense. My goal would be to allow this from the user point of view, regardless of the (possibly) awful metaprogramming hacks to allow it.

Note : if it is possible, I would like a solution without boost (only the standard library) to understand correctly all the details of the method.


A class template parameter is either a type or a value, so i can't think of a trick to handle both when instantiating classes directly. Functions are a different story, so let's introduce a make function:

template <typename T> struct myclass {};

template <int V> struct value {}; // helper

template <typename T> myclass<T>        make_myclass() { return myclass<T>(); }
template <int V>      myclass<value<V>> make_myclass() { return myclass<value<V>>(); }

int main(int argc, char** argv)
    auto a = make_myclass<void>();
    auto b = make_myclass<double>();
    auto c = make_myclass<42>();

Close enough?

Need Your Help

jQuery POST request from inside an iFrame times out

jquery html ajax iframe bookmarklet

I have an iframe that is injected into an arbitrary webpage by a bookmarklet. It points to http://localhost:5000/test, which is a simple HTML page that runs the following Javascript:

simple-xml preserve comments and ignored elements on deserialization/serialization

java xml serialization jaxb simple-framework

I'm using Simple framework deserialize an xml into an object, modify it and serialize it again.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.