Skip to content

Commit

Permalink
opt:add constraint to the method readu32sizeanddata method (#2090)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang authored Jan 20, 2025
1 parent 359c8c3 commit de94439
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/dict/utils/dictfile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <string>
#include <vector>
#include <QMutex>
#include <type_traits>
#include <string>

/// File utilities
namespace File {
Expand Down Expand Up @@ -80,6 +82,9 @@ public:
template< typename T >
void readU32SizeAndData( T & container )
{
static_assert( std::is_same< T, std::vector< unsigned char > >::value
|| std::is_same< T, std::vector< char > >::value || std::is_same< T, std::string >::value,
"T must be either std::vector<char> or std::string" );
uint32_t size = 0;
read( &size, sizeof( uint32_t ) );
if ( size > 0 ) {
Expand Down

0 comments on commit de94439

Please sign in to comment.