[LLVMdev] Is it possible using anonymous namespace on template in header files.

罗勇刚(Yonggang Luo) luoyonggang at gmail.com
Sun Sep 13 04:06:12 PDT 2009


for example
  /// getPointerUnionTypeNum - If the argument has type PT1* or PT2* return
  /// false or true respectively.
  template <typename PT1, typename PT2>
  static inline int getPointerUnionTypeNum(PT1 *P) { return 0; }
  template <typename PT1, typename PT2>
  static inline int getPointerUnionTypeNum(PT2 *P) { return 1; }
  template <typename PT1, typename PT2>
  static inline int getPointerUnionTypeNum(...) { return -1; }

it's a peace of code comes from PointerUnion.h

can it change to be
namespace{
  template <typename PT1, typename PT2>
  inline int getPointerUnionTypeNum(PT1 *P) { return 0; }
  template <typename PT1, typename PT2>
  inline int getPointerUnionTypeNum(PT2 *P) { return 1; }
  template <typename PT1, typename PT2>
  inline int getPointerUnionTypeNum(...) { return -1; }
}




-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo




More information about the llvm-dev mailing list