@@ -152,28 +152,32 @@ namespace osuCrypto
152152 template <typename T>
153153 BitReference bit (T&& data, u64 index)
154154 {
155- if constexpr (bit_compatable_container<T>::value)
155+ using TT = std::remove_cvref_t <T>;
156+ if constexpr (bit_compatable_container<TT>::value)
156157 {
157- static_assert (std::is_trivially_copyable_v<typename T ::value_type>,
158+ static_assert (std::is_trivially_copyable_v<typename TT ::value_type>,
158159 " bit(x, i) must be called with an x that is a container of trivial "
159160 " values, or be a trivial value, or a pointer to a trivial type" );
160- if (index >= sizeof (typename T ::value_type) * 8 * data.size ())
161+ if (index >= sizeof (typename TT ::value_type) * 8 * data.size ())
161162 throw RTE_LOC;
162163 return BitReference ((u8 *)data.data (), index);
163164 }
164- else if constexpr (std::is_pointer_v<T >)
165+ else if constexpr (std::is_pointer_v<TT >)
165166 {
166- static_assert (std::is_trivially_copyable_v<std::remove_pointer_t <T >>,
167+ static_assert (std::is_trivially_copyable_v<std::remove_pointer_t <TT >>,
167168 " bit(x, i) must be called with an x that is a container of trivial "
168169 " values, or be a trivial value, or a pointer to a trivial type" );
169170 return BitReference ((u8 *)data, index);
170171 }
171172 else
172173 {
173- static_assert (std::is_trivially_copyable_v<T>,
174+ static_assert (
175+ bit_compatable_container<TT>::value ||
176+ std::is_pointer_v<TT> ||
177+ std::is_trivially_copyable_v<TT>,
174178 " bit(x, i) must be called with an x that is a container of trivial "
175179 " values, or be a trivial value, or a pointer to a trivial type" );
176- if (index >= sizeof (T ) * 8 )
180+ if (index >= sizeof (TT ) * 8 )
177181 throw RTE_LOC;
178182
179183 return BitReference ((u8 *)&data, index);
0 commit comments