44 lines
914 B
Plaintext
44 lines
914 B
Plaintext
// 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
|
|
}
|
|
|
|
inline void inlib_vdata_check_compile() {std::vector<double> v;vec_data(v);}
|
|
|
|
}
|
|
|
|
#endif
|