Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:39:07

0001 #ifndef GENERS_IOISCONTIGUOUS_HH_
0002 #define GENERS_IOISCONTIGUOUS_HH_
0003 
0004 #include <string>
0005 #include <vector>
0006 
0007 namespace gs {
0008   template <class T>
0009   struct IOIsContiguous {
0010     enum { value = 0 };
0011   };
0012 
0013   // String is treated as a pod vector. This will be guaranteed
0014   // to work correctly in the C++11 standard. The current standard
0015   // does not specify that the characters must be stored contuguously
0016   // inside the string -- however, this is always true in practice.
0017   template <class T, class Traits, class Alloc>
0018   struct IOIsContiguous<std::basic_string<T, Traits, Alloc>> {
0019     enum { value = 1 };
0020   };
0021 
0022   template <class T, class Traits, class Alloc>
0023   struct IOIsContiguous<const std::basic_string<T, Traits, Alloc>> {
0024     enum { value = 1 };
0025   };
0026 
0027   template <class T, class Traits, class Alloc>
0028   struct IOIsContiguous<volatile std::basic_string<T, Traits, Alloc>> {
0029     enum { value = 1 };
0030   };
0031 
0032   template <class T, class Traits, class Alloc>
0033   struct IOIsContiguous<const volatile std::basic_string<T, Traits, Alloc>> {
0034     enum { value = 1 };
0035   };
0036 
0037   // std::vector is used by the package everywhere. No point in not
0038   // having it here.
0039   template <class T, class Alloc>
0040   struct IOIsContiguous<std::vector<T, Alloc>> {
0041     enum { value = 1 };
0042   };
0043 
0044   template <class T, class Alloc>
0045   struct IOIsContiguous<const std::vector<T, Alloc>> {
0046     enum { value = 1 };
0047   };
0048 
0049   template <class T, class Alloc>
0050   struct IOIsContiguous<volatile std::vector<T, Alloc>> {
0051     enum { value = 1 };
0052   };
0053 
0054   template <class T, class Alloc>
0055   struct IOIsContiguous<const volatile std::vector<T, Alloc>> {
0056     enum { value = 1 };
0057   };
0058 
0059   // Hovever, std::vector<bool> should be excluded
0060   template <>
0061   struct IOIsContiguous<std::vector<bool>> {
0062     enum { value = 0 };
0063   };
0064 
0065   template <>
0066   struct IOIsContiguous<const std::vector<bool>> {
0067     enum { value = 0 };
0068   };
0069 
0070   template <>
0071   struct IOIsContiguous<volatile std::vector<bool>> {
0072     enum { value = 0 };
0073   };
0074 
0075   template <>
0076   struct IOIsContiguous<const volatile std::vector<bool>> {
0077     enum { value = 0 };
0078   };
0079 }  // namespace gs
0080 
0081 #endif  // GENERS_IOISCONTIGUOUS_HH_