Can define a class for namespace A in some other namespace B?

Discussion in 'C++' started by Peng Yu, Sep 14, 2008.

  1. Peng Yu

    Peng Yu Guest

    Hi,

    Suppose I have two namespaces A and B, I'm wondering if I can define a
    class in B for A. The question is relevant when I want to specialize
    some classes that have been defined in the std:: namespace. For
    example, I have the following code

    namespace my {
    ....
    some code // it needs the specialized version of
    std::less<std::complex<T> >
    ....
    }


    If I specialize std::less<std::complex<T> > in std::, it will be
    effective for any namespace. However, I only want it be effective for
    namespace my. I'm wondering if it is possible?

    Thanks,
    Peng
     
    Peng Yu, Sep 14, 2008
    #1
    1. Advertisements

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. ad
    Replies:
    2
    Views:
    851
  2. E11
    Replies:
    1
    Views:
    5,756
    Thomas Weidenfeller
    Oct 12, 2005
  3. theotyflos
    Replies:
    3
    Views:
    693
    Thomas Matthews
    Feb 19, 2004
  4. Alex Vinokur
    Replies:
    1
    Views:
    459
    mlimber
    Jun 6, 2006
  5. =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki

    Decralation of class inside other class and definition outside this class

    =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki, Jul 13, 2007, in forum: C++
    Replies:
    2
    Views:
    482
    Alf P. Steinbach
    Jul 13, 2007
  6. Jeremy
    Replies:
    6
    Views:
    1,460
    Jeremy
    Dec 2, 2010
  7. ThunderMusic
    Replies:
    1
    Views:
    320
    ThunderMusic
    Feb 22, 2007
  8. parmenides
    Replies:
    1
    Views:
    258
    Stefan Ram
    Aug 21, 2013
Loading...