1/* Copyright (C) 2017 Povilas Kanapickas <povilas@radix.lt>
2
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
6*/
7
8#ifndef LIBSIMDPP_SIMDPP_DETAIL_EVAL_SCALAR_H
9#define LIBSIMDPP_SIMDPP_DETAIL_EVAL_SCALAR_H
10
11#ifndef LIBSIMDPP_SIMD_H
12 #error "This file must be included through simd.h"
13#endif
14
15#include <simdpp/setup_arch.h>
16#include <simdpp/expr.h>
17#include <simdpp/detail/expr/scalar.h>
18
19namespace simdpp {
20namespace SIMDPP_ARCH_NAMESPACE {
21namespace detail {
22
23template<class R, class E>
24struct eval_maybe_scalar {
25 static SIMDPP_INL R eval(const E& e) { return (R) e.eval(); }
26};
27
28template<class R>
29struct eval_maybe_scalar<R, int> {
30 static SIMDPP_INL R eval(const int& e) { return expr_eval_scalar<R>(e); }
31};
32
33template<class R>
34struct eval_maybe_scalar<R, long> {
35 static SIMDPP_INL R eval(const long& e) { return expr_eval_scalar<R>(e); }
36};
37
38template<class R>
39struct eval_maybe_scalar<R, long long> {
40 static SIMDPP_INL R eval(const long long& e) { return expr_eval_scalar<R>(e); }
41};
42
43template<class R>
44struct eval_maybe_scalar<R, unsigned> {
45 static SIMDPP_INL R eval(const unsigned& e) { return expr_eval_scalar<R>(e); }
46};
47
48template<class R>
49struct eval_maybe_scalar<R, unsigned long> {
50 static SIMDPP_INL R eval(const unsigned long& e) { return expr_eval_scalar<R>(e); }
51};
52
53template<class R>
54struct eval_maybe_scalar<R, unsigned long long> {
55 static SIMDPP_INL R eval(const unsigned long long& e) { return expr_eval_scalar<R>(e); }
56};
57
58template<class R>
59struct eval_maybe_scalar<R, float> {
60 static SIMDPP_INL R eval(const float& e) { return expr_eval_scalar<R>(e); }
61};
62
63template<class R>
64struct eval_maybe_scalar<R, double> {
65 static SIMDPP_INL R eval(const double& e) { return expr_eval_scalar<R>(e); }
66};
67
68template<class R, class E>
69struct eval_maybe_scalar_bitwise {
70 static SIMDPP_INL R eval(const E& e) { return (R) e.eval(); }
71};
72
73template<class R>
74struct eval_maybe_scalar_bitwise<R, int> {
75 static SIMDPP_INL R eval(const int& e) { return expr_eval_scalar_bitwise<R>(e); }
76};
77
78template<class R>
79struct eval_maybe_scalar_bitwise<R, long> {
80 static SIMDPP_INL R eval(const long& e) { return expr_eval_scalar_bitwise<R>(e); }
81};
82
83template<class R>
84struct eval_maybe_scalar_bitwise<R, long long> {
85 static SIMDPP_INL R eval(const long long& e) { return expr_eval_scalar_bitwise<R>(e); }
86};
87
88template<class R>
89struct eval_maybe_scalar_bitwise<R, unsigned> {
90 static SIMDPP_INL R eval(const unsigned& e) { return expr_eval_scalar_bitwise<R>(e); }
91};
92
93template<class R>
94struct eval_maybe_scalar_bitwise<R, unsigned long> {
95 static SIMDPP_INL R eval(const unsigned long& e) { return expr_eval_scalar_bitwise<R>(e); }
96};
97
98template<class R>
99struct eval_maybe_scalar_bitwise<R, unsigned long long> {
100 static SIMDPP_INL R eval(const unsigned long long& e) { return expr_eval_scalar_bitwise<R>(e); }
101};
102
103template<class R>
104struct eval_maybe_scalar_bitwise<R, float> {
105 static SIMDPP_INL R eval(const float& e) { return expr_eval_scalar_bitwise<R>(e); }
106};
107
108template<class R>
109struct eval_maybe_scalar_bitwise<R, double> {
110 static SIMDPP_INL R eval(const double& e) { return expr_eval_scalar_bitwise<R>(e); }
111};
112
113} // namespace detail
114} // namespace SIMDPP_ARCH_NAMESPACE
115} // namespace simdpp
116
117#endif
118