Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/vdata is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_vdata
0005 #define tools_vdata
0006 
0007 #include <vector>
0008 
0009 #if defined(__APPLE__)
0010 #include <TargetConditionals.h>
0011 #endif
0012 
0013 namespace tools {
0014 
0015 // || !__GXX_EXPERIMENTAL_CXX0X__
0016 
0017 template <class T>
0018 inline const T* vec_data(const std::vector<T>& a_vec) {
0019 #if TARGET_OS_IPHONE || __INTEL_COMPILER || _MSC_VER || (__GNUC__ == 4 && __GNUC_MINOR__ <= 0)
0020   if(a_vec.empty()) return 0;
0021   const T& vf = a_vec.front();
0022   return &vf;
0023 #else
0024   return a_vec.data();
0025 #endif
0026 }
0027 
0028 template <class T>
0029 inline T* vec_data(std::vector<T>& a_vec) {
0030 #if TARGET_OS_IPHONE || __INTEL_COMPILER || _MSC_VER || (__GNUC__ == 4 && __GNUC_MINOR__ <= 0)
0031   if(a_vec.empty()) return 0;
0032   T& vf = a_vec.front();
0033   return &vf;
0034 #else
0035   return a_vec.data();
0036 #endif
0037 }
0038 
0039 /*
0040 #include "forit"
0041 //std::vector<bool>::data() does not compile. The below may do the job :
0042 inline bool* _vec_data(std::vector<bool>& a_v,bool& a_to_delete) {
0043   a_to_delete = true;
0044   bool* _data = new bool[a_v.size()+1];
0045   size_t count = 0;
0046   tools_vforcit(bool,a_v,it) {_data[count] = *it;count++;}
0047   return _data;
0048 }
0049 
0050 template <class TYPE>
0051 inline TYPE* _vec_data(std::vector<TYPE>& a_v,bool& a_to_delete) {
0052   a_to_delete = false;
0053   return vec_data(a_v);
0054 }
0055 */
0056 
0057 inline void tools_vdata_check_compile() {std::vector<double> v;vec_data(v);}
0058 
0059 }
0060 
0061 #endif