Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #15005

Re: Finding out whether a class instantiates a template

From cartec69@gmail.com
Newsgroups comp.lang.c++
Subject Re: Finding out whether a class instantiates a template
Date 2012-03-22 07:49 -0700
Organization http://groups.google.com
Message-ID <31706691.24.1332427767247.JavaMail.geo-discussion-forums@yner4> (permalink)
References <DbmdnZ4BnOh2WtPSnZ2dnUVZ_gmdnZ2d@giganews.com> <jin6mk$4fh$1@dont-email.me> <mZKdnZyfF7KVjc3SnZ2dnUVZ_oadnZ2d@giganews.com>

Show all headers | View raw


On Thursday, March 1, 2012 6:10:48 PM UTC-6, Ed Anson wrote:
> My problem involves template parameters (of class templates) -- not 
> function parameters. What I have looks something like this:
> 
> template <class T> class foo {};
> template <class U> class bar {};
> 
> where T is required to be an instantiation of bar<U>, such as
> 
> bar<foo<int> > A;
> 

I'm assuming you mean "U is required to be an instantiation of foo<>" since that's what your example is. I think it's standard practice to use a "trait" template for this:

template <typename T> struct is_foo { static const bool value = false; };
template <typename T> struct is_foo< foo<T> > { static const bool value = true; };

So T is an instation of foo iff is_foo<T>::value == true.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Finding out whether a class instantiates a template Ed Anson <EdAnson@comcast.net> - 2012-02-29 19:50 -0500
  Re: Finding out whether a class instantiates a template Christian Gollwitzer <auriocus@gmx.de> - 2012-03-01 07:58 +0100
    Re: Finding out whether a class instantiates a template Ed Anson <EdAnson@comcast.net> - 2012-03-01 19:10 -0500
      Re: Finding out whether a class instantiates a template cartec69@gmail.com - 2012-03-22 07:49 -0700
        Re: Finding out whether a class instantiates a template Ed Anson <EdAnson@comcast.net> - 2012-03-22 22:30 -0400
          Re: Finding out whether a class instantiates a template Ed Anson <EdAnson@comcast.net> - 2012-03-23 18:31 -0400
            Re: Finding out whether a class instantiates a template Marc <marc.glisse@gmail.com> - 2012-03-24 23:08 +0000

csiph-web