Re: Stuck trying to do first exercise in C++ Template Metaprogramming

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John (Eljay) Love-Jensen wrote:
------------------------------
struct Foo
{
  template <bool x>
  struct MyTemplate
  {
    enum { test = false };
  };
};

template <>
struct Foo::MyTemplate<true>
{
  enum { test = true };
};
------------------------------

Hope that helps,
Yes, thank you, it came out like this:

template<typename T,bool> struct acr_impl;
template<typename T> struct acr_impl<T,true>  { typedef T type; };
template<typename T> struct acr_impl<T,false> { typedef T& type; };

template<typename T>
struct add_const_ref
{
   typedef typename acr_impl<T,boost::is_reference<T>::value>::type type;
};

and works fine:)

Patrick


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux