Skip to content

Commit 1d38f93

Browse files
committed
Remove C++11 conditional from src/api/c.
There was a std::contitional in src/api/c. Removed it because CUDA on OSX cannot compile with C++11 on CUDA framework < 7.0
1 parent 3300941 commit 1d38f93

3 files changed

Lines changed: 34 additions & 8 deletions

File tree

src/api/c/mean.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static outType mean(const af_array &in)
3333
template<typename inType, typename outType>
3434
static outType mean(const af_array &in, const af_array &weights)
3535
{
36-
typedef baseOutType<outType> bType;
36+
typedef typename baseOutType<outType>::type bType;
3737

3838
Array<outType> input = cast<outType>(getArray<inType>(in));
3939
Array<outType> wts = cast<outType>(getArray<bType>(weights));
@@ -55,7 +55,7 @@ static af_array mean(const af_array &in, dim_type dim)
5555
template<typename inType, typename outType>
5656
static af_array mean(const af_array &in, const af_array &weights, dim_type dim)
5757
{
58-
typedef baseOutType<outType> bType;
58+
typedef typename baseOutType<outType>::type bType;
5959

6060
Array<outType> input = cast<outType>(getArray<inType>(in));
6161
Array<outType> wts = cast<outType>(getArray<bType>(weights));

src/api/c/stats.h

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,37 @@
99

1010
#pragma once
1111

12+
template<typename T, typename Other>
13+
struct is_same{
14+
static const bool value = false;
15+
};
16+
1217
template<typename T>
13-
using baseOutType = typename std::conditional< std::is_same<T, cdouble>::value ||
14-
std::is_same<T, double>::value,
15-
double,
16-
float>::type;
18+
struct is_same<T, T> {
19+
static const bool value = true;
20+
};
21+
22+
template<bool, typename T, typename O>
23+
struct cond_type;
24+
25+
template<typename T, typename Other>
26+
struct cond_type<true, T, Other> {
27+
typedef T type;
28+
};
29+
30+
template<typename T, typename Other>
31+
struct cond_type<false, T, Other> {
32+
typedef Other type;
33+
};
34+
35+
template<typename T>
36+
struct baseOutType {
37+
typedef typename cond_type< is_same<T, cdouble>::value ||
38+
is_same<T, double>::value,
39+
double,
40+
float>::type type;
41+
};
42+
1743
template<typename T>
1844
inline T mean(const Array<T>& in)
1945
{

src/api/c/var.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static outType varAll(const af_array& in, bool isbiased)
4343
template<typename inType, typename outType>
4444
static outType varAll(const af_array& in, const af_array weights)
4545
{
46-
typedef baseOutType<outType> bType;
46+
typedef typename baseOutType<outType>::type bType;
4747

4848
Array<outType> input = cast<outType>(getArray<inType>(in));
4949
Array<outType> wts = cast<outType>(getArray<bType>(weights));
@@ -91,7 +91,7 @@ static af_array var(const af_array& in, bool isbiased, int dim)
9191
template<typename inType, typename outType>
9292
static af_array var(const af_array& in, const af_array& weights, dim_type dim)
9393
{
94-
typedef baseOutType<outType> bType;
94+
typedef typename baseOutType<outType>::type bType;
9595

9696
Array<outType> input = cast<outType>(getArray<inType>(in));
9797
Array<outType> wts = cast<outType>(getArray<bType>(weights));

0 commit comments

Comments
 (0)