49 lines
918 B
C++
49 lines
918 B
C++
#ifndef PFOR_PFOR_INDEX_PROPERTY_INJECTIVE_H
|
|
#define PFOR_PFOR_INDEX_PROPERTY_INJECTIVE_H
|
|
|
|
#include "../../mp/pack.h"
|
|
#include "../index.h"
|
|
#include "traits.h"
|
|
|
|
namespace pfor {
|
|
namespace index {
|
|
|
|
namespace prop {
|
|
|
|
struct Injective;
|
|
|
|
}
|
|
|
|
template<typename L, typename R>
|
|
struct ComputeProperty<prop::Injective, op::Minus, L, R> {
|
|
using type = Pack<prop::Injective>;
|
|
};
|
|
|
|
/**
|
|
* @brief tags an index expression as injective
|
|
*/
|
|
template<typename Expr, typename P>
|
|
auto injective(IndexImpl<Expr, P>) {
|
|
return IndexImpl<Expr, AddProperties<P, Pack<prop::Injective>>>{};
|
|
}
|
|
|
|
/**
|
|
* @brief tests if an index has injective property
|
|
*
|
|
* @param Index an index
|
|
*
|
|
* @return true if Index is injective
|
|
*/
|
|
template<typename Index>
|
|
struct IsInjective {
|
|
static constexpr bool value = hasProperties<Index, Pack<prop::Injective>>;
|
|
};
|
|
|
|
template<typename Index>
|
|
constexpr bool isInjective = IsInjective<Index>::value;
|
|
|
|
}
|
|
}
|
|
|
|
#endif
|