You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-10Lines changed: 12 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -280,20 +280,18 @@ int main() {
280
280
}
281
281
```
282
282
283
-
NULL values (DEPRICATED)
283
+
NULL values (C++17)
284
284
----
285
-
**Note: this option is deprecated and will be removed in future versions.**
286
-
You can enable boost support by defining _MODERN_SQLITE_BOOST_OPTIONAL_SUPPORT before importing sqlite_modern_cpp header.
285
+
You can use `std::optional<T>` as an alternative for `std::unique_ptr<T>` to work with NULL values.
287
286
288
287
```c++
289
-
#define_MODERN_SQLITE_BOOST_OPTIONAL_SUPPORT
290
288
#include<sqlite_modern_cpp.h>
291
289
292
290
structUser {
293
291
long long _id;
294
-
boost::optional<int> age;
295
-
boost::optional<string> name;
296
-
boost::optional<real> weight;
292
+
std::optional<int> age;
293
+
std::optional<string> name;
294
+
std::optional<real> weight;
297
295
};
298
296
299
297
{
@@ -317,9 +315,9 @@ You can enable boost support by defining _MODERN_SQLITE_BOOST_OPTIONAL_SUPPORT b
317
315
db << "select _id,age,name,weight from user where age > ? ;"
318
316
<< 18
319
317
>> [&](long long id,
320
-
boost::optional<int> age,
321
-
boost::optional<string> name
322
-
boost::optional<real> weight) {
318
+
std::optional<int> age,
319
+
std::optional<string> name
320
+
std::optional<real> weight) {
323
321
324
322
User user;
325
323
user._id = id;
@@ -336,6 +334,10 @@ You can enable boost support by defining _MODERN_SQLITE_BOOST_OPTIONAL_SUPPORT b
336
334
}
337
335
```
338
336
337
+
If you do not have C++17 support, you can use boost optional instead by defining `_MODERN_SQLITE_BOOST_OPTIONAL_SUPPORT` before importing the `sqlite_modern_cpp` header.
338
+
339
+
**Note: boost support is deprecated and will be removed in future versions.**
340
+
339
341
Variant type support (C++17)
340
342
----
341
343
If your columns may have flexible types, you can use C++17's `std::variant` to extract the value.
0 commit comments