@@ -40,15 +40,15 @@ class SignedBigInteger {
40
40
{
41
41
}
42
42
43
- static SignedBigInteger create_invalid ()
43
+ [[nodiscard]] static SignedBigInteger create_invalid ()
44
44
{
45
45
return { UnsignedBigInteger::create_invalid (), false };
46
46
}
47
47
48
- static SignedBigInteger import_data (StringView data) { return import_data ((u8 const *)data.characters_without_null_termination (), data.length ()); }
49
- static SignedBigInteger import_data (u8 const * ptr, size_t length);
48
+ [[nodiscard]] static SignedBigInteger import_data (StringView data) { return import_data ((u8 const *)data.characters_without_null_termination (), data.length ()); }
49
+ [[nodiscard]] static SignedBigInteger import_data (u8 const * ptr, size_t length);
50
50
51
- static SignedBigInteger create_from (i64 value)
51
+ [[nodiscard]] static SignedBigInteger create_from (i64 value)
52
52
{
53
53
auto sign = false ;
54
54
u64 unsigned_value;
@@ -63,15 +63,15 @@ class SignedBigInteger {
63
63
64
64
size_t export_data (Bytes, bool remove_leading_zeros = false ) const ;
65
65
66
- static SignedBigInteger from_base (u16 N, StringView str);
67
- String to_base (u16 N) const ;
66
+ [[nodiscard]] static SignedBigInteger from_base (u16 N, StringView str);
67
+ [[nodiscard]] String to_base (u16 N) const ;
68
68
69
- u64 to_u64 () const ;
70
- double to_double () const ;
69
+ [[nodiscard]] u64 to_u64 () const ;
70
+ [[nodiscard]] double to_double () const ;
71
71
72
- UnsignedBigInteger const & unsigned_value () const { return m_unsigned_data; }
73
- Vector<u32 , STARTING_WORD_SIZE> const words () const { return m_unsigned_data.words (); }
74
- bool is_negative () const { return m_sign; }
72
+ [[nodiscard]] UnsignedBigInteger const & unsigned_value () const { return m_unsigned_data; }
73
+ [[nodiscard]] Vector<u32 , STARTING_WORD_SIZE> const words () const { return m_unsigned_data.words (); }
74
+ [[nodiscard]] bool is_negative () const { return m_sign; }
75
75
76
76
void negate ()
77
77
{
@@ -101,42 +101,42 @@ class SignedBigInteger {
101
101
m_unsigned_data.invalidate ();
102
102
}
103
103
104
- bool is_invalid () const { return m_unsigned_data.is_invalid (); }
104
+ [[nodiscard]] bool is_invalid () const { return m_unsigned_data.is_invalid (); }
105
105
106
106
// These get + 1 byte for the sign.
107
- size_t length () const { return m_unsigned_data.length () + 1 ; }
108
- size_t trimmed_length () const { return m_unsigned_data.trimmed_length () + 1 ; };
109
-
110
- SignedBigInteger plus (SignedBigInteger const & other) const ;
111
- SignedBigInteger minus (SignedBigInteger const & other) const ;
112
- SignedBigInteger bitwise_or (SignedBigInteger const & other) const ;
113
- SignedBigInteger bitwise_and (SignedBigInteger const & other) const ;
114
- SignedBigInteger bitwise_xor (SignedBigInteger const & other) const ;
115
- SignedBigInteger bitwise_not () const ;
116
- SignedBigInteger shift_left (size_t num_bits) const ;
117
- SignedBigInteger multiplied_by (SignedBigInteger const & other) const ;
118
- SignedDivisionResult divided_by (SignedBigInteger const & divisor) const ;
119
-
120
- SignedBigInteger plus (UnsignedBigInteger const & other) const ;
121
- SignedBigInteger minus (UnsignedBigInteger const & other) const ;
122
- SignedBigInteger multiplied_by (UnsignedBigInteger const & other) const ;
123
- SignedDivisionResult divided_by (UnsignedBigInteger const & divisor) const ;
124
-
125
- u32 hash () const ;
107
+ [[nodiscard]] size_t length () const { return m_unsigned_data.length () + 1 ; }
108
+ [[nodiscard]] size_t trimmed_length () const { return m_unsigned_data.trimmed_length () + 1 ; };
109
+
110
+ [[nodiscard]] SignedBigInteger plus (SignedBigInteger const & other) const ;
111
+ [[nodiscard]] SignedBigInteger minus (SignedBigInteger const & other) const ;
112
+ [[nodiscard]] SignedBigInteger bitwise_or (SignedBigInteger const & other) const ;
113
+ [[nodiscard]] SignedBigInteger bitwise_and (SignedBigInteger const & other) const ;
114
+ [[nodiscard]] SignedBigInteger bitwise_xor (SignedBigInteger const & other) const ;
115
+ [[nodiscard]] SignedBigInteger bitwise_not () const ;
116
+ [[nodiscard]] SignedBigInteger shift_left (size_t num_bits) const ;
117
+ [[nodiscard]] SignedBigInteger multiplied_by (SignedBigInteger const & other) const ;
118
+ [[nodiscard]] SignedDivisionResult divided_by (SignedBigInteger const & divisor) const ;
119
+
120
+ [[nodiscard]] SignedBigInteger plus (UnsignedBigInteger const & other) const ;
121
+ [[nodiscard]] SignedBigInteger minus (UnsignedBigInteger const & other) const ;
122
+ [[nodiscard]] SignedBigInteger multiplied_by (UnsignedBigInteger const & other) const ;
123
+ [[nodiscard]] SignedDivisionResult divided_by (UnsignedBigInteger const & divisor) const ;
124
+
125
+ [[nodiscard]] u32 hash () const ;
126
126
127
127
void set_bit_inplace (size_t bit_index);
128
128
129
- bool operator ==(SignedBigInteger const & other) const ;
130
- bool operator !=(SignedBigInteger const & other) const ;
131
- bool operator <(SignedBigInteger const & other) const ;
132
- bool operator <=(SignedBigInteger const & other) const ;
133
- bool operator >(SignedBigInteger const & other) const ;
134
- bool operator >=(SignedBigInteger const & other) const ;
135
-
136
- bool operator ==(UnsignedBigInteger const & other) const ;
137
- bool operator !=(UnsignedBigInteger const & other) const ;
138
- bool operator <(UnsignedBigInteger const & other) const ;
139
- bool operator >(UnsignedBigInteger const & other) const ;
129
+ [[nodiscard]] bool operator ==(SignedBigInteger const & other) const ;
130
+ [[nodiscard]] bool operator !=(SignedBigInteger const & other) const ;
131
+ [[nodiscard]] bool operator <(SignedBigInteger const & other) const ;
132
+ [[nodiscard]] bool operator <=(SignedBigInteger const & other) const ;
133
+ [[nodiscard]] bool operator >(SignedBigInteger const & other) const ;
134
+ [[nodiscard]] bool operator >=(SignedBigInteger const & other) const ;
135
+
136
+ [[nodiscard]] bool operator ==(UnsignedBigInteger const & other) const ;
137
+ [[nodiscard]] bool operator !=(UnsignedBigInteger const & other) const ;
138
+ [[nodiscard]] bool operator <(UnsignedBigInteger const & other) const ;
139
+ [[nodiscard]] bool operator >(UnsignedBigInteger const & other) const ;
140
140
141
141
private:
142
142
void ensure_sign_is_valid ()
0 commit comments