default typedefs initlisation

Discussion in 'C++' started by Abhishek Saksena, Jun 7, 2005.

  1. Does anybody know how I can achieve the following

    I have different flavors of base class :-
    ========================
    class base //empty class
    {

    };

    class base //base class with x_type defination
    {
    public:
    typedef int x_type;
    }

    class base //base class with y_type defination
    {
    public:
    typedef int y_ype;
    }

    class base //base class with x_type and y_type defination
    {
    public:
    typedef int x_type;
    typedef int y_ype;
    }
    ==========================

    now I want to use one of these base class as a template parameter to some
    other class. Something like

    template<typaname T>
    class xyz
    {
    typedef typename T::x_type x_type;
    typedef typename T::y_type y_type;
    };

    The issue is that if the both or one of the types not defined in the base
    class then I would like to initialize the x_type and y_type (defined in
    class xyz) to some default type like bool.(without generating the
    compile-time error)


    Abhishek
     
    Abhishek Saksena, Jun 7, 2005
    #1
    1. Advertising

  2. Abhishek Saksena

    Me Guest

    Re: default typedefs initlisation

    > The issue is that if the both or one of the types not defined in the base
    > class then I would like to initialize the x_type and y_type (defined in
    > class xyz) to some default type like bool.(without generating the
    > compile-time error)


    http://www.boost.org/libs/utility/enable_if.html
     
    Me, Jun 7, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexander Stippler

    Re: visibility of typedefs

    Alexander Stippler, Jun 24, 2003, in forum: C++
    Replies:
    5
    Views:
    840
    tom_usenet
    Jun 25, 2003
  2. emerth
    Replies:
    3
    Views:
    391
    emerth
    Aug 8, 2003
  3. dwrayment

    Templates and Typedefs

    dwrayment, Aug 12, 2003, in forum: C++
    Replies:
    6
    Views:
    415
    Sam Holden
    Aug 14, 2003
  4. Dave
    Replies:
    4
    Views:
    829
    Andrey Tarasevich
    Dec 5, 2003
  5. cppaddict

    too many typedefs

    cppaddict, Jun 19, 2004, in forum: C++
    Replies:
    2
    Views:
    370
    cppaddict
    Jun 19, 2004
Loading...

Share This Page