aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorEddie Hung <eddie@fpgeh.com>2019-09-13 11:13:57 -0700
committerEddie Hung <eddie@fpgeh.com>2019-09-13 11:13:57 -0700
commit5473e597bf5aa7a5dc7c831be332baeeddae086f (patch)
treed982d9a492ca96e961a27cc15139a5008c70abcb /kernel
parent95e80809a5801743fabb2836fa25f3c3732a9a24 (diff)
downloadyosys-5473e597bf5aa7a5dc7c831be332baeeddae086f.tar.gz
yosys-5473e597bf5aa7a5dc7c831be332baeeddae086f.tar.bz2
yosys-5473e597bf5aa7a5dc7c831be332baeeddae086f.zip
Use template specialisation
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sigtools.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/sigtools.h b/kernel/sigtools.h
index 2f2d3f5c6..8c0434ceb 100644
--- a/kernel/sigtools.h
+++ b/kernel/sigtools.h
@@ -135,10 +135,10 @@ struct SigPool
}
};
-template <typename T, class Compare = std::less<T>>
+template <typename T, class Compare=void>
struct SigSet
{
- static_assert(!std::is_pointer<T>::value || !std::is_same<Compare, std::less<T>>::value, "Explicit `Compare' class required for SigSet with pointer-type values!");
+ static_assert(!std::is_same<Compare,void>::value, "Default value for `Compare' class not found for SigSet<T>. Please specify.");
struct bitDef_t : public std::pair<RTLIL::Wire*, int> {
bitDef_t() : std::pair<RTLIL::Wire*, int>(NULL, 0) { }
@@ -222,6 +222,13 @@ struct SigSet
}
};
+template<typename T>
+class SigSet<T, typename std::enable_if<!std::is_pointer<T>::value>::type> : public SigSet<T, std::less<T>> {};
+template<typename T>
+using sort_by_name_id_guard = typename std::enable_if<std::is_same<T,RTLIL::Cell*>::value>::type;
+template<typename T>
+class SigSet<T, sort_by_name_id_guard<T>> : public SigSet<T, RTLIL::sort_by_name_id<typename std::remove_pointer<T>::type>> {};
+
struct SigMap
{
mfp<SigBit> database;