36
36
#include < cstdint>
37
37
38
38
#include " detail/constants.hpp"
39
+ #include " traits.hpp"
39
40
40
41
namespace kitty
41
42
{
@@ -120,6 +121,25 @@ struct static_truth_table<NumVars, true>
120
121
*/
121
122
inline auto crend () const noexcept { return ( &_bits ) + 1 ; }
122
123
124
+ /* ! \brief Assign other truth table if number of variables match.
125
+
126
+ This replaces the current truth table with another truth table, if `other`
127
+ has the same number of variables. Otherwise, the truth table is not
128
+ changed.
129
+
130
+ \param other Other truth table
131
+ */
132
+ template <class TT , typename = std::enable_if_t <is_truth_table<TT>::value>>
133
+ static_truth_table<NumVars>& operator =( const TT& other )
134
+ {
135
+ if ( other.num_vars () == num_vars () )
136
+ {
137
+ std::copy ( other.begin (), other.end (), begin () );
138
+ }
139
+
140
+ return *this ;
141
+ }
142
+
123
143
/* ! Masks the number of valid truth table bits.
124
144
125
145
If the truth table has less than 6 variables, it may not use all
@@ -220,6 +240,25 @@ struct static_truth_table<NumVars, false>
220
240
*/
221
241
inline auto crend () const noexcept { return _bits.crend (); }
222
242
243
+ /* ! \brief Assign other truth table if number of variables match.
244
+
245
+ This replaces the current truth table with another truth table, if `other`
246
+ has the same number of variables. Otherwise, the truth table is not
247
+ changed.
248
+
249
+ \param other Other truth table
250
+ */
251
+ template <class TT , typename = std::enable_if_t <is_truth_table<TT>::value>>
252
+ static_truth_table<NumVars>& operator =( const TT& other )
253
+ {
254
+ if ( other.num_vars () == num_vars () )
255
+ {
256
+ std::copy ( other.begin (), other.end (), begin () );
257
+ }
258
+
259
+ return *this ;
260
+ }
261
+
223
262
/* ! Masks the number of valid truth table bits.
224
263
225
264
We know that we will have at least 7 variables in this data
@@ -232,4 +271,8 @@ struct static_truth_table<NumVars, false>
232
271
std::array<uint64_t , NumBlocks> _bits;
233
272
/* ! \endcond */
234
273
};
274
+
275
+ template <int NumVars>
276
+ struct is_truth_table <kitty::static_truth_table<NumVars>> : std::true_type {};
277
+
235
278
} // namespace kitty
0 commit comments