Import Geant4 11.0.0.beta source tree
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_vdata
|
||||
#define tools_vdata
|
||||
|
||||
#include <vector>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
namespace tools {
|
||||
|
||||
// || !__GXX_EXPERIMENTAL_CXX0X__
|
||||
|
||||
template <class T>
|
||||
inline const T* vec_data(const std::vector<T>& a_vec) {
|
||||
#if TARGET_OS_IPHONE || __INTEL_COMPILER || _MSC_VER || (__GNUC__ == 4 && __GNUC_MINOR__ <= 0)
|
||||
if(a_vec.empty()) return 0;
|
||||
const T& vf = a_vec.front();
|
||||
return &vf;
|
||||
#else
|
||||
return a_vec.data();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T* vec_data(std::vector<T>& a_vec) {
|
||||
#if TARGET_OS_IPHONE || __INTEL_COMPILER || _MSC_VER || (__GNUC__ == 4 && __GNUC_MINOR__ <= 0)
|
||||
if(a_vec.empty()) return 0;
|
||||
T& vf = a_vec.front();
|
||||
return &vf;
|
||||
#else
|
||||
return a_vec.data();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
#include "forit"
|
||||
//std::vector<bool>::data() does not compile. The below may do the job :
|
||||
inline bool* _vec_data(std::vector<bool>& a_v,bool& a_to_delete) {
|
||||
a_to_delete = true;
|
||||
bool* _data = new bool[a_v.size()+1];
|
||||
size_t count = 0;
|
||||
tools_vforcit(bool,a_v,it) {_data[count] = *it;count++;}
|
||||
return _data;
|
||||
}
|
||||
|
||||
template <class TYPE>
|
||||
inline TYPE* _vec_data(std::vector<TYPE>& a_v,bool& a_to_delete) {
|
||||
a_to_delete = false;
|
||||
return vec_data(a_v);
|
||||
}
|
||||
*/
|
||||
|
||||
inline void tools_vdata_check_compile() {std::vector<double> v;vec_data(v);}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user