diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-12-14 10:19:40 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-12-14 10:19:40 -0500 |
commit | 6218b88920120dea23d605856b9d27f9deb4746c (patch) | |
tree | 657840cc60749db1e8ee453593211cd336462e98 /lib/token.cpp | |
parent | c498cfa5cfd6408b465e45409987467b47b2b73d (diff) | |
download | verbly-6218b88920120dea23d605856b9d27f9deb4746c.tar.gz verbly-6218b88920120dea23d605856b9d27f9deb4746c.tar.bz2 verbly-6218b88920120dea23d605856b9d27f9deb4746c.zip |
Migrate from mpark::variant to std::variant
Diffstat (limited to 'lib/token.cpp')
-rw-r--r-- | lib/token.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/token.cpp b/lib/token.cpp index b3c7062..6b78f53 100644 --- a/lib/token.cpp +++ b/lib/token.cpp | |||
@@ -23,7 +23,7 @@ namespace verbly { | |||
23 | 23 | ||
24 | case type::utterance: | 24 | case type::utterance: |
25 | { | 25 | { |
26 | const utterance_type& utterance = mpark::get<utterance_type>(variant_); | 26 | const utterance_type& utterance = std::get<utterance_type>(variant_); |
27 | 27 | ||
28 | return std::all_of( | 28 | return std::all_of( |
29 | std::begin(utterance), | 29 | std::begin(utterance), |
@@ -35,7 +35,7 @@ namespace verbly { | |||
35 | 35 | ||
36 | case type::transform: | 36 | case type::transform: |
37 | { | 37 | { |
38 | const transform_type& transform = mpark::get<transform_type>(variant_); | 38 | const transform_type& transform = std::get<transform_type>(variant_); |
39 | 39 | ||
40 | return transform.inner->isComplete(); | 40 | return transform.inner->isComplete(); |
41 | } | 41 | } |
@@ -56,7 +56,7 @@ namespace verbly { | |||
56 | { | 56 | { |
57 | case type::word: | 57 | case type::word: |
58 | { | 58 | { |
59 | const word_type& w = mpark::get<word_type>(variant_); | 59 | const word_type& w = std::get<word_type>(variant_); |
60 | 60 | ||
61 | const form& wordForm = w.value.getInflections(w.category).front(); | 61 | const form& wordForm = w.value.getInflections(w.category).front(); |
62 | 62 | ||
@@ -108,7 +108,7 @@ namespace verbly { | |||
108 | 108 | ||
109 | case type::literal: | 109 | case type::literal: |
110 | { | 110 | { |
111 | std::string result = mpark::get<literal_type>(variant_); | 111 | std::string result = std::get<literal_type>(variant_); |
112 | 112 | ||
113 | if (indefiniteArticle && std::isalpha(result[0])) | 113 | if (indefiniteArticle && std::isalpha(result[0])) |
114 | { | 114 | { |
@@ -164,7 +164,7 @@ namespace verbly { | |||
164 | 164 | ||
165 | case type::utterance: | 165 | case type::utterance: |
166 | { | 166 | { |
167 | const utterance_type& utterance = mpark::get<utterance_type>(variant_); | 167 | const utterance_type& utterance = std::get<utterance_type>(variant_); |
168 | 168 | ||
169 | bool first = true; | 169 | bool first = true; |
170 | std::list<std::string> compiled; | 170 | std::list<std::string> compiled; |
@@ -192,7 +192,7 @@ namespace verbly { | |||
192 | 192 | ||
193 | case type::transform: | 193 | case type::transform: |
194 | { | 194 | { |
195 | const transform_type& transform = mpark::get<transform_type>(variant_); | 195 | const transform_type& transform = std::get<transform_type>(variant_); |
196 | 196 | ||
197 | switch (transform.type) | 197 | switch (transform.type) |
198 | { | 198 | { |
@@ -257,7 +257,7 @@ namespace verbly { | |||
257 | throw std::domain_error("Token is not a word"); | 257 | throw std::domain_error("Token is not a word"); |
258 | } | 258 | } |
259 | 259 | ||
260 | return mpark::get<word_type>(variant_).value; | 260 | return std::get<word_type>(variant_).value; |
261 | } | 261 | } |
262 | 262 | ||
263 | token token::inflect(inflection category) const | 263 | token token::inflect(inflection category) const |
@@ -268,7 +268,7 @@ namespace verbly { | |||
268 | } | 268 | } |
269 | 269 | ||
270 | return { | 270 | return { |
271 | mpark::get<word_type>(variant_).value, | 271 | std::get<word_type>(variant_).value, |
272 | category | 272 | category |
273 | }; | 273 | }; |
274 | } | 274 | } |
@@ -293,7 +293,7 @@ namespace verbly { | |||
293 | throw std::domain_error("Token is not a literal"); | 293 | throw std::domain_error("Token is not a literal"); |
294 | } | 294 | } |
295 | 295 | ||
296 | return mpark::get<literal_type>(variant_); | 296 | return std::get<literal_type>(variant_); |
297 | } | 297 | } |
298 | 298 | ||
299 | token::token( | 299 | token::token( |
@@ -310,7 +310,7 @@ namespace verbly { | |||
310 | throw std::domain_error("Token is not a part"); | 310 | throw std::domain_error("Token is not a part"); |
311 | } | 311 | } |
312 | 312 | ||
313 | return mpark::get<part>(variant_); | 313 | return std::get<part>(variant_); |
314 | } | 314 | } |
315 | 315 | ||
316 | token::token( | 316 | token::token( |
@@ -327,7 +327,7 @@ namespace verbly { | |||
327 | throw std::domain_error("Token is not a fillin"); | 327 | throw std::domain_error("Token is not a fillin"); |
328 | } | 328 | } |
329 | 329 | ||
330 | return mpark::get<fillin_type>(variant_); | 330 | return std::get<fillin_type>(variant_); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool token::hasSynrestr(std::string synrestr) const | 333 | bool token::hasSynrestr(std::string synrestr) const |
@@ -337,7 +337,7 @@ namespace verbly { | |||
337 | throw std::domain_error("Token is not a fillin"); | 337 | throw std::domain_error("Token is not a fillin"); |
338 | } | 338 | } |
339 | 339 | ||
340 | return mpark::get<fillin_type>(variant_).count(synrestr); | 340 | return std::get<fillin_type>(variant_).count(synrestr); |
341 | } | 341 | } |
342 | 342 | ||
343 | void token::addSynrestr(std::string synrestr) | 343 | void token::addSynrestr(std::string synrestr) |
@@ -347,7 +347,7 @@ namespace verbly { | |||
347 | throw std::domain_error("Token is not a fillin"); | 347 | throw std::domain_error("Token is not a fillin"); |
348 | } | 348 | } |
349 | 349 | ||
350 | fillin_type& fillin = mpark::get<fillin_type>(variant_); | 350 | fillin_type& fillin = std::get<fillin_type>(variant_); |
351 | fillin.insert(std::move(synrestr)); | 351 | fillin.insert(std::move(synrestr)); |
352 | } | 352 | } |
353 | 353 | ||
@@ -378,7 +378,7 @@ namespace verbly { | |||
378 | throw std::domain_error("Token is not an utterance"); | 378 | throw std::domain_error("Token is not an utterance"); |
379 | } | 379 | } |
380 | 380 | ||
381 | return std::begin(mpark::get<utterance_type>(variant_)); | 381 | return std::begin(std::get<utterance_type>(variant_)); |
382 | } | 382 | } |
383 | 383 | ||
384 | token::const_iterator token::begin() const | 384 | token::const_iterator token::begin() const |
@@ -388,7 +388,7 @@ namespace verbly { | |||
388 | throw std::domain_error("Token is not an utterance"); | 388 | throw std::domain_error("Token is not an utterance"); |
389 | } | 389 | } |
390 | 390 | ||
391 | return std::begin(mpark::get<utterance_type>(variant_)); | 391 | return std::begin(std::get<utterance_type>(variant_)); |
392 | } | 392 | } |
393 | 393 | ||
394 | token::iterator token::end() | 394 | token::iterator token::end() |
@@ -398,7 +398,7 @@ namespace verbly { | |||
398 | throw std::domain_error("Token is not an utterance"); | 398 | throw std::domain_error("Token is not an utterance"); |
399 | } | 399 | } |
400 | 400 | ||
401 | return std::end(mpark::get<utterance_type>(variant_)); | 401 | return std::end(std::get<utterance_type>(variant_)); |
402 | } | 402 | } |
403 | 403 | ||
404 | token::const_iterator token::end() const | 404 | token::const_iterator token::end() const |
@@ -408,7 +408,7 @@ namespace verbly { | |||
408 | throw std::domain_error("Token is not an utterance"); | 408 | throw std::domain_error("Token is not an utterance"); |
409 | } | 409 | } |
410 | 410 | ||
411 | return std::end(mpark::get<utterance_type>(variant_)); | 411 | return std::end(std::get<utterance_type>(variant_)); |
412 | } | 412 | } |
413 | 413 | ||
414 | token& token::operator<<(token arg) | 414 | token& token::operator<<(token arg) |
@@ -418,7 +418,7 @@ namespace verbly { | |||
418 | throw std::domain_error("Token is not an utterance"); | 418 | throw std::domain_error("Token is not an utterance"); |
419 | } | 419 | } |
420 | 420 | ||
421 | utterance_type& utterance = mpark::get<utterance_type>(variant_); | 421 | utterance_type& utterance = std::get<utterance_type>(variant_); |
422 | utterance.push_back(std::move(arg)); | 422 | utterance.push_back(std::move(arg)); |
423 | 423 | ||
424 | return *this; | 424 | return *this; |
@@ -460,7 +460,7 @@ namespace verbly { | |||
460 | throw std::domain_error("Invalid access on non-tranform token"); | 460 | throw std::domain_error("Invalid access on non-tranform token"); |
461 | } | 461 | } |
462 | 462 | ||
463 | return *mpark::get<transform_type>(variant_).inner; | 463 | return *std::get<transform_type>(variant_).inner; |
464 | } | 464 | } |
465 | 465 | ||
466 | const token& token::getInnerToken() const | 466 | const token& token::getInnerToken() const |
@@ -470,7 +470,7 @@ namespace verbly { | |||
470 | throw std::domain_error("Invalid access on non-tranform token"); | 470 | throw std::domain_error("Invalid access on non-tranform token"); |
471 | } | 471 | } |
472 | 472 | ||
473 | return *mpark::get<transform_type>(variant_).inner; | 473 | return *std::get<transform_type>(variant_).inner; |
474 | } | 474 | } |
475 | 475 | ||
476 | token::token( | 476 | token::token( |