Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:52

0001 #ifndef GENERS_IOISCONTAINER_HH_
0002 #define GENERS_IOISCONTAINER_HH_
0003 
0004 #include <string>
0005 
0006 namespace gs {
0007   // In the following template, enum "IsContainer" is evaluated to 1
0008   // at compile time if T has T::value_type typedef
0009   template <typename T>
0010   class IOIsContainer {
0011   private:
0012     typedef char One;
0013     typedef struct {
0014       char a[2];
0015     } Two;
0016     template <typename C>
0017     static One test(typename C::value_type const *);
0018     template <typename C>
0019     static Two test(...);
0020 
0021   public:
0022     enum { value = sizeof(IOIsContainer<T>::template test<T>(nullptr)) == 1 };
0023   };
0024 
0025   // Char strings get a special treatment
0026   template <>
0027   class IOIsContainer<std::string> {
0028   public:
0029     enum { value = 0 };
0030   };
0031 
0032   template <>
0033   class IOIsContainer<const std::string> {
0034   public:
0035     enum { value = 0 };
0036   };
0037 
0038   template <>
0039   class IOIsContainer<volatile std::string> {
0040   public:
0041     enum { value = 0 };
0042   };
0043 
0044   template <>
0045   class IOIsContainer<const volatile std::string> {
0046   public:
0047     enum { value = 0 };
0048   };
0049 }  // namespace gs
0050 
0051 #endif  // GENERS_IOISCONTAINER_HH_