OSSIA
Open Scenario System for Interactive Application
dataspace_base_variants.hpp
1 struct angle_u
2 {
3 public:
4  struct dummy_t
5  {
6  };
7  union Impl
8  {
9  ossia::degree_u m_value0;
10 
11  ossia::radian_u m_value1;
12 
13  dummy_t m_dummy;
14  Impl()
15  : m_dummy{}
16  {
17  }
18  ~Impl() = default;
19  };
20 
21  enum Type : int8_t
22  {
23  Type0,
24  Type1,
26  };
27 
28  Impl m_impl;
29  Type m_type;
30 
31 public:
32  static const constexpr auto npos = Npos;
33  int which() const { return m_type; }
34 
35  operator bool() const { return m_type != npos; }
36  template <typename T>
37  const T* target() const;
38  template <typename T>
39  T* target();
40  template <typename T>
41  const T& get() const;
42  template <typename T>
43  T& get();
44 
45  template <typename T>
46  static Type matching_type();
47  angle_u()
48  : m_type{Npos}
49  {
50  }
51  ~angle_u() = default;
52  angle_u(ossia::degree_u v)
53  : m_type{Type0}
54  {
55  new(&m_impl.m_value0) ossia::degree_u{v};
56  }
57  angle_u(ossia::radian_u v)
58  : m_type{Type1}
59  {
60  new(&m_impl.m_value1) ossia::radian_u{v};
61  }
62  angle_u(const angle_u& other)
63  : m_type{other.m_type}
64  {
65  switch(m_type)
66  {
67  case Type::Type0:
68  new(&m_impl.m_value0) ossia::degree_u{other.m_impl.m_value0};
69  break;
70  case Type::Type1:
71  new(&m_impl.m_value1) ossia::radian_u{other.m_impl.m_value1};
72  break;
73  default:
74  break;
75  }
76  }
77  angle_u(angle_u&& other) noexcept
78  : m_type{other.m_type}
79  {
80  switch(m_type)
81  {
82  case Type::Type0:
83  new(&m_impl.m_value0) ossia::degree_u{std::move(other.m_impl.m_value0)};
84  break;
85  case Type::Type1:
86  new(&m_impl.m_value1) ossia::radian_u{std::move(other.m_impl.m_value1)};
87  break;
88  default:
89  break;
90  }
91  }
92  angle_u& operator=(const angle_u& other)
93  {
94  m_type = other.m_type;
95  switch(m_type)
96  {
97  case Type::Type0:
98  new(&m_impl.m_value0) ossia::degree_u{other.m_impl.m_value0};
99  break;
100  case Type::Type1:
101  new(&m_impl.m_value1) ossia::radian_u{other.m_impl.m_value1};
102  break;
103  default:
104  break;
105  }
106  return *this;
107  }
108  angle_u& operator=(angle_u&& other) noexcept
109  {
110  m_type = other.m_type;
111  switch(m_type)
112  {
113  case Type::Type0:
114  new(&m_impl.m_value0) ossia::degree_u{std::move(other.m_impl.m_value0)};
115  break;
116  case Type::Type1:
117  new(&m_impl.m_value1) ossia::radian_u{std::move(other.m_impl.m_value1)};
118  break;
119  default:
120  break;
121  }
122  return *this;
123  }
124 };
125 template <>
126 inline const ossia::degree_u* angle_u::target() const
127 {
128  if(m_type == Type0)
129  return &m_impl.m_value0;
130  return nullptr;
131 }
132 template <>
133 inline const ossia::radian_u* angle_u::target() const
134 {
135  if(m_type == Type1)
136  return &m_impl.m_value1;
137  return nullptr;
138 }
139 template <>
140 inline ossia::degree_u* angle_u::target()
141 {
142  if(m_type == Type0)
143  return &m_impl.m_value0;
144  return nullptr;
145 }
146 template <>
147 inline ossia::radian_u* angle_u::target()
148 {
149  if(m_type == Type1)
150  return &m_impl.m_value1;
151  return nullptr;
152 }
153 template <>
154 inline const ossia::degree_u& angle_u::get() const
155 {
156  if(m_type == Type0)
157  return m_impl.m_value0;
158  ossia_do_throw(std::runtime_error, "angle_u: bad type");
159 }
160 template <>
161 inline const ossia::radian_u& angle_u::get() const
162 {
163  if(m_type == Type1)
164  return m_impl.m_value1;
165  ossia_do_throw(std::runtime_error, "angle_u: bad type");
166 }
167 template <>
168 inline ossia::degree_u& angle_u::get()
169 {
170  if(m_type == Type0)
171  return m_impl.m_value0;
172  ossia_do_throw(std::runtime_error, "angle_u: bad type");
173 }
174 template <>
175 inline ossia::radian_u& angle_u::get()
176 {
177  if(m_type == Type1)
178  return m_impl.m_value1;
179  ossia_do_throw(std::runtime_error, "angle_u: bad type");
180 }
181 template <typename Visitor>
182 auto apply_nonnull(Visitor&& functor, const angle_u& var)
183 {
184  switch(var.m_type)
185  {
186  case angle_u::Type::Type0:
187  return functor(var.m_impl.m_value0);
188  case angle_u::Type::Type1:
189  return functor(var.m_impl.m_value1);
190  default:
191  ossia_do_throw(std::runtime_error, "angle_u: bad type");
192  }
193 }
194 template <typename Visitor>
195 auto apply_nonnull(Visitor&& functor, angle_u& var)
196 {
197  switch(var.m_type)
198  {
199  case angle_u::Type::Type0:
200  return functor(var.m_impl.m_value0);
201  case angle_u::Type::Type1:
202  return functor(var.m_impl.m_value1);
203  default:
204  ossia_do_throw(std::runtime_error, "angle_u: bad type");
205  }
206 }
207 template <typename Visitor>
208 auto apply_nonnull(Visitor&& functor, angle_u&& var)
209 {
210  switch(var.m_type)
211  {
212  case angle_u::Type::Type0:
213  return functor(std::move(var.m_impl.m_value0));
214  case angle_u::Type::Type1:
215  return functor(std::move(var.m_impl.m_value1));
216  default:
217  ossia_do_throw(std::runtime_error, "angle_u: bad type");
218  }
219 }
220 template <typename Visitor>
221 auto apply(Visitor&& functor, const angle_u& var)
222 {
223  switch(var.m_type)
224  {
225  case angle_u::Type::Type0:
226  return functor(var.m_impl.m_value0);
227  case angle_u::Type::Type1:
228  return functor(var.m_impl.m_value1);
229  default:
230  return functor();
231  }
232 }
233 template <typename Visitor>
234 auto apply(Visitor&& functor, angle_u& var)
235 {
236  switch(var.m_type)
237  {
238  case angle_u::Type::Type0:
239  return functor(var.m_impl.m_value0);
240  case angle_u::Type::Type1:
241  return functor(var.m_impl.m_value1);
242  default:
243  return functor();
244  }
245 }
246 template <typename Visitor>
247 auto apply(Visitor&& functor, angle_u&& var)
248 {
249  switch(var.m_type)
250  {
251  case angle_u::Type::Type0:
252  return functor(std::move(var.m_impl.m_value0));
253  case angle_u::Type::Type1:
254  return functor(std::move(var.m_impl.m_value1));
255  default:
256  return functor();
257  }
258 }
259 inline bool operator==(const angle_u& lhs, const angle_u& rhs)
260 {
261  return (lhs.m_type == rhs.m_type);
262 }
263 inline bool operator!=(const angle_u& lhs, const angle_u& rhs)
264 {
265  return (lhs.m_type != rhs.m_type);
266 }
267 inline bool operator==(const angle_u& lhs, const ossia::degree_u& rhs)
268 {
269  return (lhs.m_type == angle_u::Type::Type0);
270 }
271 inline bool operator==(const ossia::degree_u& lhs, const angle_u& rhs)
272 {
273  return (rhs.m_type == angle_u::Type::Type0);
274 }
275 inline bool operator!=(const angle_u& lhs, const ossia::degree_u& rhs)
276 {
277  return (lhs.m_type != angle_u::Type::Type0);
278 }
279 inline bool operator!=(const ossia::degree_u& lhs, const angle_u& rhs)
280 {
281  return (rhs.m_type != angle_u::Type::Type0);
282 }
283 inline bool operator==(const angle_u& lhs, const ossia::radian_u& rhs)
284 {
285  return (lhs.m_type == angle_u::Type::Type1);
286 }
287 inline bool operator==(const ossia::radian_u& lhs, const angle_u& rhs)
288 {
289  return (rhs.m_type == angle_u::Type::Type1);
290 }
291 inline bool operator!=(const angle_u& lhs, const ossia::radian_u& rhs)
292 {
293  return (lhs.m_type != angle_u::Type::Type1);
294 }
295 inline bool operator!=(const ossia::radian_u& lhs, const angle_u& rhs)
296 {
297  return (rhs.m_type != angle_u::Type::Type1);
298 }
299 struct color_u
300 {
301 public:
302  struct dummy_t
303  {
304  };
305  union Impl
306  {
307  ossia::argb_u m_value0;
308 
309  ossia::rgba_u m_value1;
310 
311  ossia::rgb_u m_value2;
312 
313  ossia::bgr_u m_value3;
314 
315  ossia::argb8_u m_value4;
316 
317  ossia::rgba8_u m_value5;
318 
319  ossia::hsv_u m_value6;
320 
321  ossia::cmy8_u m_value7;
322 
323  ossia::xyz_u m_value8;
324 
325  dummy_t m_dummy;
326  Impl()
327  : m_dummy{}
328  {
329  }
330  ~Impl() = default;
331  };
332 
333  enum Type : int8_t
334  {
335  Type0,
336  Type1,
337  Type2,
338  Type3,
339  Type4,
340  Type5,
341  Type6,
342  Type7,
343  Type8,
345  };
346 
347  Impl m_impl;
348  Type m_type;
349 
350 public:
351  static const constexpr auto npos = Npos;
352  int which() const { return m_type; }
353 
354  operator bool() const { return m_type != npos; }
355  template <typename T>
356  const T* target() const;
357  template <typename T>
358  T* target();
359  template <typename T>
360  const T& get() const;
361  template <typename T>
362  T& get();
363 
364  template <typename T>
365  static Type matching_type();
366  color_u()
367  : m_type{Npos}
368  {
369  }
370  ~color_u() = default;
371  color_u(ossia::argb_u v)
372  : m_type{Type0}
373  {
374  new(&m_impl.m_value0) ossia::argb_u{v};
375  }
376  color_u(ossia::rgba_u v)
377  : m_type{Type1}
378  {
379  new(&m_impl.m_value1) ossia::rgba_u{v};
380  }
381  color_u(ossia::rgb_u v)
382  : m_type{Type2}
383  {
384  new(&m_impl.m_value2) ossia::rgb_u{v};
385  }
386  color_u(ossia::bgr_u v)
387  : m_type{Type3}
388  {
389  new(&m_impl.m_value3) ossia::bgr_u{v};
390  }
391  color_u(ossia::argb8_u v)
392  : m_type{Type4}
393  {
394  new(&m_impl.m_value4) ossia::argb8_u{v};
395  }
396  color_u(ossia::rgba8_u v)
397  : m_type{Type5}
398  {
399  new(&m_impl.m_value5) ossia::rgba8_u{v};
400  }
401  color_u(ossia::hsv_u v)
402  : m_type{Type6}
403  {
404  new(&m_impl.m_value6) ossia::hsv_u{v};
405  }
406  color_u(ossia::cmy8_u v)
407  : m_type{Type7}
408  {
409  new(&m_impl.m_value7) ossia::cmy8_u{v};
410  }
411  color_u(ossia::xyz_u v)
412  : m_type{Type8}
413  {
414  new(&m_impl.m_value8) ossia::xyz_u{v};
415  }
416  color_u(const color_u& other)
417  : m_type{other.m_type}
418  {
419  switch(m_type)
420  {
421  case Type::Type0:
422  new(&m_impl.m_value0) ossia::argb_u{other.m_impl.m_value0};
423  break;
424  case Type::Type1:
425  new(&m_impl.m_value1) ossia::rgba_u{other.m_impl.m_value1};
426  break;
427  case Type::Type2:
428  new(&m_impl.m_value2) ossia::rgb_u{other.m_impl.m_value2};
429  break;
430  case Type::Type3:
431  new(&m_impl.m_value3) ossia::bgr_u{other.m_impl.m_value3};
432  break;
433  case Type::Type4:
434  new(&m_impl.m_value4) ossia::argb8_u{other.m_impl.m_value4};
435  break;
436  case Type::Type5:
437  new(&m_impl.m_value5) ossia::rgba8_u{other.m_impl.m_value5};
438  break;
439  case Type::Type6:
440  new(&m_impl.m_value6) ossia::hsv_u{other.m_impl.m_value6};
441  break;
442  case Type::Type7:
443  new(&m_impl.m_value7) ossia::cmy8_u{other.m_impl.m_value7};
444  break;
445  case Type::Type8:
446  new(&m_impl.m_value8) ossia::xyz_u{other.m_impl.m_value8};
447  break;
448  default:
449  break;
450  }
451  }
452  color_u(color_u&& other) noexcept
453  : m_type{other.m_type}
454  {
455  switch(m_type)
456  {
457  case Type::Type0:
458  new(&m_impl.m_value0) ossia::argb_u{std::move(other.m_impl.m_value0)};
459  break;
460  case Type::Type1:
461  new(&m_impl.m_value1) ossia::rgba_u{std::move(other.m_impl.m_value1)};
462  break;
463  case Type::Type2:
464  new(&m_impl.m_value2) ossia::rgb_u{std::move(other.m_impl.m_value2)};
465  break;
466  case Type::Type3:
467  new(&m_impl.m_value3) ossia::bgr_u{std::move(other.m_impl.m_value3)};
468  break;
469  case Type::Type4:
470  new(&m_impl.m_value4) ossia::argb8_u{std::move(other.m_impl.m_value4)};
471  break;
472  case Type::Type5:
473  new(&m_impl.m_value5) ossia::rgba8_u{std::move(other.m_impl.m_value5)};
474  break;
475  case Type::Type6:
476  new(&m_impl.m_value6) ossia::hsv_u{std::move(other.m_impl.m_value6)};
477  break;
478  case Type::Type7:
479  new(&m_impl.m_value7) ossia::cmy8_u{std::move(other.m_impl.m_value7)};
480  break;
481  case Type::Type8:
482  new(&m_impl.m_value8) ossia::xyz_u{std::move(other.m_impl.m_value8)};
483  break;
484  default:
485  break;
486  }
487  }
488  color_u& operator=(const color_u& other)
489  {
490 
491  m_type = other.m_type;
492  switch(m_type)
493  {
494  case Type::Type0:
495  new(&m_impl.m_value0) ossia::argb_u{other.m_impl.m_value0};
496  break;
497  case Type::Type1:
498  new(&m_impl.m_value1) ossia::rgba_u{other.m_impl.m_value1};
499  break;
500  case Type::Type2:
501  new(&m_impl.m_value2) ossia::rgb_u{other.m_impl.m_value2};
502  break;
503  case Type::Type3:
504  new(&m_impl.m_value3) ossia::bgr_u{other.m_impl.m_value3};
505  break;
506  case Type::Type4:
507  new(&m_impl.m_value4) ossia::argb8_u{other.m_impl.m_value4};
508  break;
509  case Type::Type5:
510  new(&m_impl.m_value5) ossia::rgba8_u{other.m_impl.m_value5};
511  break;
512  case Type::Type6:
513  new(&m_impl.m_value6) ossia::hsv_u{other.m_impl.m_value6};
514  break;
515  case Type::Type7:
516  new(&m_impl.m_value7) ossia::cmy8_u{other.m_impl.m_value7};
517  break;
518  case Type::Type8:
519  new(&m_impl.m_value8) ossia::xyz_u{other.m_impl.m_value8};
520  break;
521  default:
522  break;
523  }
524  return *this;
525  }
526  color_u& operator=(color_u&& other) noexcept
527  {
528 
529  m_type = other.m_type;
530  switch(m_type)
531  {
532  case Type::Type0:
533  new(&m_impl.m_value0) ossia::argb_u{std::move(other.m_impl.m_value0)};
534  break;
535  case Type::Type1:
536  new(&m_impl.m_value1) ossia::rgba_u{std::move(other.m_impl.m_value1)};
537  break;
538  case Type::Type2:
539  new(&m_impl.m_value2) ossia::rgb_u{std::move(other.m_impl.m_value2)};
540  break;
541  case Type::Type3:
542  new(&m_impl.m_value3) ossia::bgr_u{std::move(other.m_impl.m_value3)};
543  break;
544  case Type::Type4:
545  new(&m_impl.m_value4) ossia::argb8_u{std::move(other.m_impl.m_value4)};
546  break;
547  case Type::Type5:
548  new(&m_impl.m_value5) ossia::rgba8_u{std::move(other.m_impl.m_value5)};
549  break;
550  case Type::Type6:
551  new(&m_impl.m_value6) ossia::hsv_u{std::move(other.m_impl.m_value6)};
552  break;
553  case Type::Type7:
554  new(&m_impl.m_value7) ossia::cmy8_u{std::move(other.m_impl.m_value7)};
555  break;
556  case Type::Type8:
557  new(&m_impl.m_value8) ossia::xyz_u{std::move(other.m_impl.m_value8)};
558  break;
559  default:
560  break;
561  }
562  return *this;
563  }
564 };
565 template <>
566 inline const ossia::argb_u* color_u::target() const
567 {
568  if(m_type == Type0)
569  return &m_impl.m_value0;
570  return nullptr;
571 }
572 template <>
573 inline const ossia::rgba_u* color_u::target() const
574 {
575  if(m_type == Type1)
576  return &m_impl.m_value1;
577  return nullptr;
578 }
579 template <>
580 inline const ossia::rgb_u* color_u::target() const
581 {
582  if(m_type == Type2)
583  return &m_impl.m_value2;
584  return nullptr;
585 }
586 template <>
587 inline const ossia::bgr_u* color_u::target() const
588 {
589  if(m_type == Type3)
590  return &m_impl.m_value3;
591  return nullptr;
592 }
593 template <>
594 inline const ossia::argb8_u* color_u::target() const
595 {
596  if(m_type == Type4)
597  return &m_impl.m_value4;
598  return nullptr;
599 }
600 template <>
601 inline const ossia::rgba8_u* color_u::target() const
602 {
603  if(m_type == Type5)
604  return &m_impl.m_value5;
605  return nullptr;
606 }
607 template <>
608 inline const ossia::hsv_u* color_u::target() const
609 {
610  if(m_type == Type6)
611  return &m_impl.m_value6;
612  return nullptr;
613 }
614 template <>
615 inline const ossia::cmy8_u* color_u::target() const
616 {
617  if(m_type == Type7)
618  return &m_impl.m_value7;
619  return nullptr;
620 }
621 template <>
622 inline const ossia::xyz_u* color_u::target() const
623 {
624  if(m_type == Type8)
625  return &m_impl.m_value8;
626  return nullptr;
627 }
628 template <>
629 inline ossia::argb_u* color_u::target()
630 {
631  if(m_type == Type0)
632  return &m_impl.m_value0;
633  return nullptr;
634 }
635 template <>
636 inline ossia::rgba_u* color_u::target()
637 {
638  if(m_type == Type1)
639  return &m_impl.m_value1;
640  return nullptr;
641 }
642 template <>
643 inline ossia::rgb_u* color_u::target()
644 {
645  if(m_type == Type2)
646  return &m_impl.m_value2;
647  return nullptr;
648 }
649 template <>
650 inline ossia::bgr_u* color_u::target()
651 {
652  if(m_type == Type3)
653  return &m_impl.m_value3;
654  return nullptr;
655 }
656 template <>
657 inline ossia::argb8_u* color_u::target()
658 {
659  if(m_type == Type4)
660  return &m_impl.m_value4;
661  return nullptr;
662 }
663 template <>
664 inline ossia::rgba8_u* color_u::target()
665 {
666  if(m_type == Type5)
667  return &m_impl.m_value5;
668  return nullptr;
669 }
670 template <>
671 inline ossia::hsv_u* color_u::target()
672 {
673  if(m_type == Type6)
674  return &m_impl.m_value6;
675  return nullptr;
676 }
677 template <>
678 inline ossia::cmy8_u* color_u::target()
679 {
680  if(m_type == Type7)
681  return &m_impl.m_value7;
682  return nullptr;
683 }
684 template <>
685 inline ossia::xyz_u* color_u::target()
686 {
687  if(m_type == Type8)
688  return &m_impl.m_value8;
689  return nullptr;
690 }
691 template <>
692 inline const ossia::argb_u& color_u::get() const
693 {
694  if(m_type == Type0)
695  return m_impl.m_value0;
696  ossia_do_throw(std::runtime_error, "color_u: bad type");
697 }
698 template <>
699 inline const ossia::rgba_u& color_u::get() const
700 {
701  if(m_type == Type1)
702  return m_impl.m_value1;
703  ossia_do_throw(std::runtime_error, "color_u: bad type");
704 }
705 template <>
706 inline const ossia::rgb_u& color_u::get() const
707 {
708  if(m_type == Type2)
709  return m_impl.m_value2;
710  ossia_do_throw(std::runtime_error, "color_u: bad type");
711 }
712 template <>
713 inline const ossia::bgr_u& color_u::get() const
714 {
715  if(m_type == Type3)
716  return m_impl.m_value3;
717  ossia_do_throw(std::runtime_error, "color_u: bad type");
718 }
719 template <>
720 inline const ossia::argb8_u& color_u::get() const
721 {
722  if(m_type == Type4)
723  return m_impl.m_value4;
724  ossia_do_throw(std::runtime_error, "color_u: bad type");
725 }
726 template <>
727 inline const ossia::rgba8_u& color_u::get() const
728 {
729  if(m_type == Type5)
730  return m_impl.m_value5;
731  ossia_do_throw(std::runtime_error, "color_u: bad type");
732 }
733 template <>
734 inline const ossia::hsv_u& color_u::get() const
735 {
736  if(m_type == Type6)
737  return m_impl.m_value6;
738  ossia_do_throw(std::runtime_error, "color_u: bad type");
739 }
740 template <>
741 inline const ossia::cmy8_u& color_u::get() const
742 {
743  if(m_type == Type7)
744  return m_impl.m_value7;
745  ossia_do_throw(std::runtime_error, "color_u: bad type");
746 }
747 template <>
748 inline const ossia::xyz_u& color_u::get() const
749 {
750  if(m_type == Type8)
751  return m_impl.m_value8;
752  ossia_do_throw(std::runtime_error, "color_u: bad type");
753 }
754 template <>
755 inline ossia::argb_u& color_u::get()
756 {
757  if(m_type == Type0)
758  return m_impl.m_value0;
759  ossia_do_throw(std::runtime_error, "color_u: bad type");
760 }
761 template <>
762 inline ossia::rgba_u& color_u::get()
763 {
764  if(m_type == Type1)
765  return m_impl.m_value1;
766  ossia_do_throw(std::runtime_error, "color_u: bad type");
767 }
768 template <>
769 inline ossia::rgb_u& color_u::get()
770 {
771  if(m_type == Type2)
772  return m_impl.m_value2;
773  ossia_do_throw(std::runtime_error, "color_u: bad type");
774 }
775 template <>
776 inline ossia::bgr_u& color_u::get()
777 {
778  if(m_type == Type3)
779  return m_impl.m_value3;
780  ossia_do_throw(std::runtime_error, "color_u: bad type");
781 }
782 template <>
783 inline ossia::argb8_u& color_u::get()
784 {
785  if(m_type == Type4)
786  return m_impl.m_value4;
787  ossia_do_throw(std::runtime_error, "color_u: bad type");
788 }
789 template <>
790 inline ossia::rgba8_u& color_u::get()
791 {
792  if(m_type == Type5)
793  return m_impl.m_value5;
794  ossia_do_throw(std::runtime_error, "color_u: bad type");
795 }
796 template <>
797 inline ossia::hsv_u& color_u::get()
798 {
799  if(m_type == Type6)
800  return m_impl.m_value6;
801  ossia_do_throw(std::runtime_error, "color_u: bad type");
802 }
803 template <>
804 inline ossia::cmy8_u& color_u::get()
805 {
806  if(m_type == Type7)
807  return m_impl.m_value7;
808  ossia_do_throw(std::runtime_error, "color_u: bad type");
809 }
810 template <>
811 inline ossia::xyz_u& color_u::get()
812 {
813  if(m_type == Type8)
814  return m_impl.m_value8;
815  ossia_do_throw(std::runtime_error, "color_u: bad type");
816 }
817 template <typename Visitor>
818 auto apply_nonnull(Visitor&& functor, const color_u& var)
819 {
820  switch(var.m_type)
821  {
822  case color_u::Type::Type0:
823  return functor(var.m_impl.m_value0);
824  case color_u::Type::Type1:
825  return functor(var.m_impl.m_value1);
826  case color_u::Type::Type2:
827  return functor(var.m_impl.m_value2);
828  case color_u::Type::Type3:
829  return functor(var.m_impl.m_value3);
830  case color_u::Type::Type4:
831  return functor(var.m_impl.m_value4);
832  case color_u::Type::Type5:
833  return functor(var.m_impl.m_value5);
834  case color_u::Type::Type6:
835  return functor(var.m_impl.m_value6);
836  case color_u::Type::Type7:
837  return functor(var.m_impl.m_value7);
838  case color_u::Type::Type8:
839  return functor(var.m_impl.m_value8);
840  default:
841  ossia_do_throw(std::runtime_error, "color_u: bad type");
842  }
843 }
844 template <typename Visitor>
845 auto apply_nonnull(Visitor&& functor, color_u& var)
846 {
847  switch(var.m_type)
848  {
849  case color_u::Type::Type0:
850  return functor(var.m_impl.m_value0);
851  case color_u::Type::Type1:
852  return functor(var.m_impl.m_value1);
853  case color_u::Type::Type2:
854  return functor(var.m_impl.m_value2);
855  case color_u::Type::Type3:
856  return functor(var.m_impl.m_value3);
857  case color_u::Type::Type4:
858  return functor(var.m_impl.m_value4);
859  case color_u::Type::Type5:
860  return functor(var.m_impl.m_value5);
861  case color_u::Type::Type6:
862  return functor(var.m_impl.m_value6);
863  case color_u::Type::Type7:
864  return functor(var.m_impl.m_value7);
865  case color_u::Type::Type8:
866  return functor(var.m_impl.m_value8);
867  default:
868  ossia_do_throw(std::runtime_error, "color_u: bad type");
869  }
870 }
871 template <typename Visitor>
872 auto apply_nonnull(Visitor&& functor, color_u&& var)
873 {
874  switch(var.m_type)
875  {
876  case color_u::Type::Type0:
877  return functor(std::move(var.m_impl.m_value0));
878  case color_u::Type::Type1:
879  return functor(std::move(var.m_impl.m_value1));
880  case color_u::Type::Type2:
881  return functor(std::move(var.m_impl.m_value2));
882  case color_u::Type::Type3:
883  return functor(std::move(var.m_impl.m_value3));
884  case color_u::Type::Type4:
885  return functor(std::move(var.m_impl.m_value4));
886  case color_u::Type::Type5:
887  return functor(std::move(var.m_impl.m_value5));
888  case color_u::Type::Type6:
889  return functor(std::move(var.m_impl.m_value6));
890  case color_u::Type::Type7:
891  return functor(std::move(var.m_impl.m_value7));
892  case color_u::Type::Type8:
893  return functor(std::move(var.m_impl.m_value8));
894  default:
895  ossia_do_throw(std::runtime_error, "color_u: bad type");
896  }
897 }
898 template <typename Visitor>
899 auto apply(Visitor&& functor, const color_u& var)
900 {
901  switch(var.m_type)
902  {
903  case color_u::Type::Type0:
904  return functor(var.m_impl.m_value0);
905  case color_u::Type::Type1:
906  return functor(var.m_impl.m_value1);
907  case color_u::Type::Type2:
908  return functor(var.m_impl.m_value2);
909  case color_u::Type::Type3:
910  return functor(var.m_impl.m_value3);
911  case color_u::Type::Type4:
912  return functor(var.m_impl.m_value4);
913  case color_u::Type::Type5:
914  return functor(var.m_impl.m_value5);
915  case color_u::Type::Type6:
916  return functor(var.m_impl.m_value6);
917  case color_u::Type::Type7:
918  return functor(var.m_impl.m_value7);
919  case color_u::Type::Type8:
920  return functor(var.m_impl.m_value8);
921  default:
922  return functor();
923  }
924 }
925 template <typename Visitor>
926 auto apply(Visitor&& functor, color_u& var)
927 {
928  switch(var.m_type)
929  {
930  case color_u::Type::Type0:
931  return functor(var.m_impl.m_value0);
932  case color_u::Type::Type1:
933  return functor(var.m_impl.m_value1);
934  case color_u::Type::Type2:
935  return functor(var.m_impl.m_value2);
936  case color_u::Type::Type3:
937  return functor(var.m_impl.m_value3);
938  case color_u::Type::Type4:
939  return functor(var.m_impl.m_value4);
940  case color_u::Type::Type5:
941  return functor(var.m_impl.m_value5);
942  case color_u::Type::Type6:
943  return functor(var.m_impl.m_value6);
944  case color_u::Type::Type7:
945  return functor(var.m_impl.m_value7);
946  case color_u::Type::Type8:
947  return functor(var.m_impl.m_value8);
948  default:
949  return functor();
950  }
951 }
952 template <typename Visitor>
953 auto apply(Visitor&& functor, color_u&& var)
954 {
955  switch(var.m_type)
956  {
957  case color_u::Type::Type0:
958  return functor(std::move(var.m_impl.m_value0));
959  case color_u::Type::Type1:
960  return functor(std::move(var.m_impl.m_value1));
961  case color_u::Type::Type2:
962  return functor(std::move(var.m_impl.m_value2));
963  case color_u::Type::Type3:
964  return functor(std::move(var.m_impl.m_value3));
965  case color_u::Type::Type4:
966  return functor(std::move(var.m_impl.m_value4));
967  case color_u::Type::Type5:
968  return functor(std::move(var.m_impl.m_value5));
969  case color_u::Type::Type6:
970  return functor(std::move(var.m_impl.m_value6));
971  case color_u::Type::Type7:
972  return functor(std::move(var.m_impl.m_value7));
973  case color_u::Type::Type8:
974  return functor(std::move(var.m_impl.m_value8));
975  default:
976  return functor();
977  }
978 }
979 inline bool operator==(const color_u& lhs, const color_u& rhs)
980 {
981  return (lhs.m_type == rhs.m_type);
982 }
983 inline bool operator!=(const color_u& lhs, const color_u& rhs)
984 {
985  return (lhs.m_type != rhs.m_type);
986 }
987 inline bool operator==(const color_u& lhs, const ossia::argb_u& rhs)
988 {
989  return (lhs.m_type == color_u::Type::Type0);
990 }
991 inline bool operator==(const ossia::argb_u& lhs, const color_u& rhs)
992 {
993  return (rhs.m_type == color_u::Type::Type0);
994 }
995 inline bool operator!=(const color_u& lhs, const ossia::argb_u& rhs)
996 {
997  return (lhs.m_type != color_u::Type::Type0);
998 }
999 inline bool operator!=(const ossia::argb_u& lhs, const color_u& rhs)
1000 {
1001  return (rhs.m_type != color_u::Type::Type0);
1002 }
1003 inline bool operator==(const color_u& lhs, const ossia::rgba_u& rhs)
1004 {
1005  return (lhs.m_type == color_u::Type::Type1);
1006 }
1007 inline bool operator==(const ossia::rgba_u& lhs, const color_u& rhs)
1008 {
1009  return (rhs.m_type == color_u::Type::Type1);
1010 }
1011 inline bool operator!=(const color_u& lhs, const ossia::rgba_u& rhs)
1012 {
1013  return (lhs.m_type != color_u::Type::Type1);
1014 }
1015 inline bool operator!=(const ossia::rgba_u& lhs, const color_u& rhs)
1016 {
1017  return (rhs.m_type != color_u::Type::Type1);
1018 }
1019 inline bool operator==(const color_u& lhs, const ossia::rgb_u& rhs)
1020 {
1021  return (lhs.m_type == color_u::Type::Type2);
1022 }
1023 inline bool operator==(const ossia::rgb_u& lhs, const color_u& rhs)
1024 {
1025  return (rhs.m_type == color_u::Type::Type2);
1026 }
1027 inline bool operator!=(const color_u& lhs, const ossia::rgb_u& rhs)
1028 {
1029  return (lhs.m_type != color_u::Type::Type2);
1030 }
1031 inline bool operator!=(const ossia::rgb_u& lhs, const color_u& rhs)
1032 {
1033  return (rhs.m_type != color_u::Type::Type2);
1034 }
1035 inline bool operator==(const color_u& lhs, const ossia::bgr_u& rhs)
1036 {
1037  return (lhs.m_type == color_u::Type::Type3);
1038 }
1039 inline bool operator==(const ossia::bgr_u& lhs, const color_u& rhs)
1040 {
1041  return (rhs.m_type == color_u::Type::Type3);
1042 }
1043 inline bool operator!=(const color_u& lhs, const ossia::bgr_u& rhs)
1044 {
1045  return (lhs.m_type != color_u::Type::Type3);
1046 }
1047 inline bool operator!=(const ossia::bgr_u& lhs, const color_u& rhs)
1048 {
1049  return (rhs.m_type != color_u::Type::Type3);
1050 }
1051 inline bool operator==(const color_u& lhs, const ossia::argb8_u& rhs)
1052 {
1053  return (lhs.m_type == color_u::Type::Type4);
1054 }
1055 inline bool operator==(const ossia::argb8_u& lhs, const color_u& rhs)
1056 {
1057  return (rhs.m_type == color_u::Type::Type4);
1058 }
1059 inline bool operator!=(const color_u& lhs, const ossia::argb8_u& rhs)
1060 {
1061  return (lhs.m_type != color_u::Type::Type4);
1062 }
1063 inline bool operator!=(const ossia::argb8_u& lhs, const color_u& rhs)
1064 {
1065  return (rhs.m_type != color_u::Type::Type4);
1066 }
1067 inline bool operator==(const color_u& lhs, const ossia::rgba8_u& rhs)
1068 {
1069  return (lhs.m_type == color_u::Type::Type5);
1070 }
1071 inline bool operator==(const ossia::rgba8_u& lhs, const color_u& rhs)
1072 {
1073  return (rhs.m_type == color_u::Type::Type5);
1074 }
1075 inline bool operator!=(const color_u& lhs, const ossia::rgba8_u& rhs)
1076 {
1077  return (lhs.m_type != color_u::Type::Type5);
1078 }
1079 inline bool operator!=(const ossia::rgba8_u& lhs, const color_u& rhs)
1080 {
1081  return (rhs.m_type != color_u::Type::Type5);
1082 }
1083 inline bool operator==(const color_u& lhs, const ossia::hsv_u& rhs)
1084 {
1085  return (lhs.m_type == color_u::Type::Type6);
1086 }
1087 inline bool operator==(const ossia::hsv_u& lhs, const color_u& rhs)
1088 {
1089  return (rhs.m_type == color_u::Type::Type6);
1090 }
1091 inline bool operator!=(const color_u& lhs, const ossia::hsv_u& rhs)
1092 {
1093  return (lhs.m_type != color_u::Type::Type6);
1094 }
1095 inline bool operator!=(const ossia::hsv_u& lhs, const color_u& rhs)
1096 {
1097  return (rhs.m_type != color_u::Type::Type6);
1098 }
1099 inline bool operator==(const color_u& lhs, const ossia::cmy8_u& rhs)
1100 {
1101  return (lhs.m_type == color_u::Type::Type7);
1102 }
1103 inline bool operator==(const ossia::cmy8_u& lhs, const color_u& rhs)
1104 {
1105  return (rhs.m_type == color_u::Type::Type7);
1106 }
1107 inline bool operator!=(const color_u& lhs, const ossia::cmy8_u& rhs)
1108 {
1109  return (lhs.m_type != color_u::Type::Type7);
1110 }
1111 inline bool operator!=(const ossia::cmy8_u& lhs, const color_u& rhs)
1112 {
1113  return (rhs.m_type != color_u::Type::Type7);
1114 }
1115 inline bool operator==(const color_u& lhs, const ossia::xyz_u& rhs)
1116 {
1117  return (lhs.m_type == color_u::Type::Type8);
1118 }
1119 inline bool operator==(const ossia::xyz_u& lhs, const color_u& rhs)
1120 {
1121  return (rhs.m_type == color_u::Type::Type8);
1122 }
1123 inline bool operator!=(const color_u& lhs, const ossia::xyz_u& rhs)
1124 {
1125  return (lhs.m_type != color_u::Type::Type8);
1126 }
1127 inline bool operator!=(const ossia::xyz_u& lhs, const color_u& rhs)
1128 {
1129  return (rhs.m_type != color_u::Type::Type8);
1130 }
1131 struct distance_u
1132 {
1133 public:
1134  struct dummy_t
1135  {
1136  };
1137  union Impl
1138  {
1139  ossia::meter_u m_value0;
1140 
1141  ossia::kilometer_u m_value1;
1142 
1143  ossia::decimeter_u m_value2;
1144 
1145  ossia::centimeter_u m_value3;
1146 
1147  ossia::millimeter_u m_value4;
1148 
1149  ossia::micrometer_u m_value5;
1150 
1151  ossia::nanometer_u m_value6;
1152 
1153  ossia::picometer_u m_value7;
1154 
1155  ossia::inch_u m_value8;
1156 
1157  ossia::foot_u m_value9;
1158 
1159  ossia::mile_u m_value10;
1160 
1161  dummy_t m_dummy;
1162  Impl()
1163  : m_dummy{}
1164  {
1165  }
1166  ~Impl() = default;
1167  };
1168 
1169  enum Type : int8_t
1170  {
1171  Type0,
1172  Type1,
1173  Type2,
1174  Type3,
1175  Type4,
1176  Type5,
1177  Type6,
1178  Type7,
1179  Type8,
1180  Type9,
1181  Type10,
1183  };
1184 
1185  Impl m_impl;
1186  Type m_type;
1187 
1188 public:
1189  static const constexpr auto npos = Npos;
1190  int which() const { return m_type; }
1191 
1192  operator bool() const { return m_type != npos; }
1193  template <typename T>
1194  const T* target() const;
1195  template <typename T>
1196  T* target();
1197  template <typename T>
1198  const T& get() const;
1199  template <typename T>
1200  T& get();
1201 
1202  template <typename T>
1203  static Type matching_type();
1204  distance_u()
1205  : m_type{Npos}
1206  {
1207  }
1208  ~distance_u() = default;
1209  distance_u(ossia::meter_u v)
1210  : m_type{Type0}
1211  {
1212  new(&m_impl.m_value0) ossia::meter_u{v};
1213  }
1214  distance_u(ossia::kilometer_u v)
1215  : m_type{Type1}
1216  {
1217  new(&m_impl.m_value1) ossia::kilometer_u{v};
1218  }
1219  distance_u(ossia::decimeter_u v)
1220  : m_type{Type2}
1221  {
1222  new(&m_impl.m_value2) ossia::decimeter_u{v};
1223  }
1224  distance_u(ossia::centimeter_u v)
1225  : m_type{Type3}
1226  {
1227  new(&m_impl.m_value3) ossia::centimeter_u{v};
1228  }
1229  distance_u(ossia::millimeter_u v)
1230  : m_type{Type4}
1231  {
1232  new(&m_impl.m_value4) ossia::millimeter_u{v};
1233  }
1234  distance_u(ossia::micrometer_u v)
1235  : m_type{Type5}
1236  {
1237  new(&m_impl.m_value5) ossia::micrometer_u{v};
1238  }
1239  distance_u(ossia::nanometer_u v)
1240  : m_type{Type6}
1241  {
1242  new(&m_impl.m_value6) ossia::nanometer_u{v};
1243  }
1244  distance_u(ossia::picometer_u v)
1245  : m_type{Type7}
1246  {
1247  new(&m_impl.m_value7) ossia::picometer_u{v};
1248  }
1249  distance_u(ossia::inch_u v)
1250  : m_type{Type8}
1251  {
1252  new(&m_impl.m_value8) ossia::inch_u{v};
1253  }
1254  distance_u(ossia::foot_u v)
1255  : m_type{Type9}
1256  {
1257  new(&m_impl.m_value9) ossia::foot_u{v};
1258  }
1259  distance_u(ossia::mile_u v)
1260  : m_type{Type10}
1261  {
1262  new(&m_impl.m_value10) ossia::mile_u{v};
1263  }
1264  distance_u(const distance_u& other)
1265  : m_type{other.m_type}
1266  {
1267  switch(m_type)
1268  {
1269  case Type::Type0:
1270  new(&m_impl.m_value0) ossia::meter_u{other.m_impl.m_value0};
1271  break;
1272  case Type::Type1:
1273  new(&m_impl.m_value1) ossia::kilometer_u{other.m_impl.m_value1};
1274  break;
1275  case Type::Type2:
1276  new(&m_impl.m_value2) ossia::decimeter_u{other.m_impl.m_value2};
1277  break;
1278  case Type::Type3:
1279  new(&m_impl.m_value3) ossia::centimeter_u{other.m_impl.m_value3};
1280  break;
1281  case Type::Type4:
1282  new(&m_impl.m_value4) ossia::millimeter_u{other.m_impl.m_value4};
1283  break;
1284  case Type::Type5:
1285  new(&m_impl.m_value5) ossia::micrometer_u{other.m_impl.m_value5};
1286  break;
1287  case Type::Type6:
1288  new(&m_impl.m_value6) ossia::nanometer_u{other.m_impl.m_value6};
1289  break;
1290  case Type::Type7:
1291  new(&m_impl.m_value7) ossia::picometer_u{other.m_impl.m_value7};
1292  break;
1293  case Type::Type8:
1294  new(&m_impl.m_value8) ossia::inch_u{other.m_impl.m_value8};
1295  break;
1296  case Type::Type9:
1297  new(&m_impl.m_value9) ossia::foot_u{other.m_impl.m_value9};
1298  break;
1299  case Type::Type10:
1300  new(&m_impl.m_value10) ossia::mile_u{other.m_impl.m_value10};
1301  break;
1302  default:
1303  break;
1304  }
1305  }
1306  distance_u(distance_u&& other) noexcept
1307  : m_type{other.m_type}
1308  {
1309  switch(m_type)
1310  {
1311  case Type::Type0:
1312  new(&m_impl.m_value0) ossia::meter_u{std::move(other.m_impl.m_value0)};
1313  break;
1314  case Type::Type1:
1315  new(&m_impl.m_value1) ossia::kilometer_u{std::move(other.m_impl.m_value1)};
1316  break;
1317  case Type::Type2:
1318  new(&m_impl.m_value2) ossia::decimeter_u{std::move(other.m_impl.m_value2)};
1319  break;
1320  case Type::Type3:
1321  new(&m_impl.m_value3) ossia::centimeter_u{std::move(other.m_impl.m_value3)};
1322  break;
1323  case Type::Type4:
1324  new(&m_impl.m_value4) ossia::millimeter_u{std::move(other.m_impl.m_value4)};
1325  break;
1326  case Type::Type5:
1327  new(&m_impl.m_value5) ossia::micrometer_u{std::move(other.m_impl.m_value5)};
1328  break;
1329  case Type::Type6:
1330  new(&m_impl.m_value6) ossia::nanometer_u{std::move(other.m_impl.m_value6)};
1331  break;
1332  case Type::Type7:
1333  new(&m_impl.m_value7) ossia::picometer_u{std::move(other.m_impl.m_value7)};
1334  break;
1335  case Type::Type8:
1336  new(&m_impl.m_value8) ossia::inch_u{std::move(other.m_impl.m_value8)};
1337  break;
1338  case Type::Type9:
1339  new(&m_impl.m_value9) ossia::foot_u{std::move(other.m_impl.m_value9)};
1340  break;
1341  case Type::Type10:
1342  new(&m_impl.m_value10) ossia::mile_u{std::move(other.m_impl.m_value10)};
1343  break;
1344  default:
1345  break;
1346  }
1347  }
1348  distance_u& operator=(const distance_u& other)
1349  {
1350 
1351  m_type = other.m_type;
1352  switch(m_type)
1353  {
1354  case Type::Type0:
1355  new(&m_impl.m_value0) ossia::meter_u{other.m_impl.m_value0};
1356  break;
1357  case Type::Type1:
1358  new(&m_impl.m_value1) ossia::kilometer_u{other.m_impl.m_value1};
1359  break;
1360  case Type::Type2:
1361  new(&m_impl.m_value2) ossia::decimeter_u{other.m_impl.m_value2};
1362  break;
1363  case Type::Type3:
1364  new(&m_impl.m_value3) ossia::centimeter_u{other.m_impl.m_value3};
1365  break;
1366  case Type::Type4:
1367  new(&m_impl.m_value4) ossia::millimeter_u{other.m_impl.m_value4};
1368  break;
1369  case Type::Type5:
1370  new(&m_impl.m_value5) ossia::micrometer_u{other.m_impl.m_value5};
1371  break;
1372  case Type::Type6:
1373  new(&m_impl.m_value6) ossia::nanometer_u{other.m_impl.m_value6};
1374  break;
1375  case Type::Type7:
1376  new(&m_impl.m_value7) ossia::picometer_u{other.m_impl.m_value7};
1377  break;
1378  case Type::Type8:
1379  new(&m_impl.m_value8) ossia::inch_u{other.m_impl.m_value8};
1380  break;
1381  case Type::Type9:
1382  new(&m_impl.m_value9) ossia::foot_u{other.m_impl.m_value9};
1383  break;
1384  case Type::Type10:
1385  new(&m_impl.m_value10) ossia::mile_u{other.m_impl.m_value10};
1386  break;
1387  default:
1388  break;
1389  }
1390  return *this;
1391  }
1392  distance_u& operator=(distance_u&& other) noexcept
1393  {
1394 
1395  m_type = other.m_type;
1396  switch(m_type)
1397  {
1398  case Type::Type0:
1399  new(&m_impl.m_value0) ossia::meter_u{std::move(other.m_impl.m_value0)};
1400  break;
1401  case Type::Type1:
1402  new(&m_impl.m_value1) ossia::kilometer_u{std::move(other.m_impl.m_value1)};
1403  break;
1404  case Type::Type2:
1405  new(&m_impl.m_value2) ossia::decimeter_u{std::move(other.m_impl.m_value2)};
1406  break;
1407  case Type::Type3:
1408  new(&m_impl.m_value3) ossia::centimeter_u{std::move(other.m_impl.m_value3)};
1409  break;
1410  case Type::Type4:
1411  new(&m_impl.m_value4) ossia::millimeter_u{std::move(other.m_impl.m_value4)};
1412  break;
1413  case Type::Type5:
1414  new(&m_impl.m_value5) ossia::micrometer_u{std::move(other.m_impl.m_value5)};
1415  break;
1416  case Type::Type6:
1417  new(&m_impl.m_value6) ossia::nanometer_u{std::move(other.m_impl.m_value6)};
1418  break;
1419  case Type::Type7:
1420  new(&m_impl.m_value7) ossia::picometer_u{std::move(other.m_impl.m_value7)};
1421  break;
1422  case Type::Type8:
1423  new(&m_impl.m_value8) ossia::inch_u{std::move(other.m_impl.m_value8)};
1424  break;
1425  case Type::Type9:
1426  new(&m_impl.m_value9) ossia::foot_u{std::move(other.m_impl.m_value9)};
1427  break;
1428  case Type::Type10:
1429  new(&m_impl.m_value10) ossia::mile_u{std::move(other.m_impl.m_value10)};
1430  break;
1431  default:
1432  break;
1433  }
1434  return *this;
1435  }
1436 };
1437 template <>
1438 inline const ossia::meter_u* distance_u::target() const
1439 {
1440  if(m_type == Type0)
1441  return &m_impl.m_value0;
1442  return nullptr;
1443 }
1444 template <>
1445 inline const ossia::kilometer_u* distance_u::target() const
1446 {
1447  if(m_type == Type1)
1448  return &m_impl.m_value1;
1449  return nullptr;
1450 }
1451 template <>
1452 inline const ossia::decimeter_u* distance_u::target() const
1453 {
1454  if(m_type == Type2)
1455  return &m_impl.m_value2;
1456  return nullptr;
1457 }
1458 template <>
1459 inline const ossia::centimeter_u* distance_u::target() const
1460 {
1461  if(m_type == Type3)
1462  return &m_impl.m_value3;
1463  return nullptr;
1464 }
1465 template <>
1466 inline const ossia::millimeter_u* distance_u::target() const
1467 {
1468  if(m_type == Type4)
1469  return &m_impl.m_value4;
1470  return nullptr;
1471 }
1472 template <>
1473 inline const ossia::micrometer_u* distance_u::target() const
1474 {
1475  if(m_type == Type5)
1476  return &m_impl.m_value5;
1477  return nullptr;
1478 }
1479 template <>
1480 inline const ossia::nanometer_u* distance_u::target() const
1481 {
1482  if(m_type == Type6)
1483  return &m_impl.m_value6;
1484  return nullptr;
1485 }
1486 template <>
1487 inline const ossia::picometer_u* distance_u::target() const
1488 {
1489  if(m_type == Type7)
1490  return &m_impl.m_value7;
1491  return nullptr;
1492 }
1493 template <>
1494 inline const ossia::inch_u* distance_u::target() const
1495 {
1496  if(m_type == Type8)
1497  return &m_impl.m_value8;
1498  return nullptr;
1499 }
1500 template <>
1501 inline const ossia::foot_u* distance_u::target() const
1502 {
1503  if(m_type == Type9)
1504  return &m_impl.m_value9;
1505  return nullptr;
1506 }
1507 template <>
1508 inline const ossia::mile_u* distance_u::target() const
1509 {
1510  if(m_type == Type10)
1511  return &m_impl.m_value10;
1512  return nullptr;
1513 }
1514 template <>
1515 inline ossia::meter_u* distance_u::target()
1516 {
1517  if(m_type == Type0)
1518  return &m_impl.m_value0;
1519  return nullptr;
1520 }
1521 template <>
1522 inline ossia::kilometer_u* distance_u::target()
1523 {
1524  if(m_type == Type1)
1525  return &m_impl.m_value1;
1526  return nullptr;
1527 }
1528 template <>
1529 inline ossia::decimeter_u* distance_u::target()
1530 {
1531  if(m_type == Type2)
1532  return &m_impl.m_value2;
1533  return nullptr;
1534 }
1535 template <>
1536 inline ossia::centimeter_u* distance_u::target()
1537 {
1538  if(m_type == Type3)
1539  return &m_impl.m_value3;
1540  return nullptr;
1541 }
1542 template <>
1543 inline ossia::millimeter_u* distance_u::target()
1544 {
1545  if(m_type == Type4)
1546  return &m_impl.m_value4;
1547  return nullptr;
1548 }
1549 template <>
1550 inline ossia::micrometer_u* distance_u::target()
1551 {
1552  if(m_type == Type5)
1553  return &m_impl.m_value5;
1554  return nullptr;
1555 }
1556 template <>
1557 inline ossia::nanometer_u* distance_u::target()
1558 {
1559  if(m_type == Type6)
1560  return &m_impl.m_value6;
1561  return nullptr;
1562 }
1563 template <>
1564 inline ossia::picometer_u* distance_u::target()
1565 {
1566  if(m_type == Type7)
1567  return &m_impl.m_value7;
1568  return nullptr;
1569 }
1570 template <>
1571 inline ossia::inch_u* distance_u::target()
1572 {
1573  if(m_type == Type8)
1574  return &m_impl.m_value8;
1575  return nullptr;
1576 }
1577 template <>
1578 inline ossia::foot_u* distance_u::target()
1579 {
1580  if(m_type == Type9)
1581  return &m_impl.m_value9;
1582  return nullptr;
1583 }
1584 template <>
1585 inline ossia::mile_u* distance_u::target()
1586 {
1587  if(m_type == Type10)
1588  return &m_impl.m_value10;
1589  return nullptr;
1590 }
1591 template <>
1592 inline const ossia::meter_u& distance_u::get() const
1593 {
1594  if(m_type == Type0)
1595  return m_impl.m_value0;
1596  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1597 }
1598 template <>
1599 inline const ossia::kilometer_u& distance_u::get() const
1600 {
1601  if(m_type == Type1)
1602  return m_impl.m_value1;
1603  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1604 }
1605 template <>
1606 inline const ossia::decimeter_u& distance_u::get() const
1607 {
1608  if(m_type == Type2)
1609  return m_impl.m_value2;
1610  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1611 }
1612 template <>
1613 inline const ossia::centimeter_u& distance_u::get() const
1614 {
1615  if(m_type == Type3)
1616  return m_impl.m_value3;
1617  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1618 }
1619 template <>
1620 inline const ossia::millimeter_u& distance_u::get() const
1621 {
1622  if(m_type == Type4)
1623  return m_impl.m_value4;
1624  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1625 }
1626 template <>
1627 inline const ossia::micrometer_u& distance_u::get() const
1628 {
1629  if(m_type == Type5)
1630  return m_impl.m_value5;
1631  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1632 }
1633 template <>
1634 inline const ossia::nanometer_u& distance_u::get() const
1635 {
1636  if(m_type == Type6)
1637  return m_impl.m_value6;
1638  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1639 }
1640 template <>
1641 inline const ossia::picometer_u& distance_u::get() const
1642 {
1643  if(m_type == Type7)
1644  return m_impl.m_value7;
1645  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1646 }
1647 template <>
1648 inline const ossia::inch_u& distance_u::get() const
1649 {
1650  if(m_type == Type8)
1651  return m_impl.m_value8;
1652  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1653 }
1654 template <>
1655 inline const ossia::foot_u& distance_u::get() const
1656 {
1657  if(m_type == Type9)
1658  return m_impl.m_value9;
1659  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1660 }
1661 template <>
1662 inline const ossia::mile_u& distance_u::get() const
1663 {
1664  if(m_type == Type10)
1665  return m_impl.m_value10;
1666  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1667 }
1668 template <>
1669 inline ossia::meter_u& distance_u::get()
1670 {
1671  if(m_type == Type0)
1672  return m_impl.m_value0;
1673  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1674 }
1675 template <>
1676 inline ossia::kilometer_u& distance_u::get()
1677 {
1678  if(m_type == Type1)
1679  return m_impl.m_value1;
1680  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1681 }
1682 template <>
1683 inline ossia::decimeter_u& distance_u::get()
1684 {
1685  if(m_type == Type2)
1686  return m_impl.m_value2;
1687  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1688 }
1689 template <>
1690 inline ossia::centimeter_u& distance_u::get()
1691 {
1692  if(m_type == Type3)
1693  return m_impl.m_value3;
1694  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1695 }
1696 template <>
1697 inline ossia::millimeter_u& distance_u::get()
1698 {
1699  if(m_type == Type4)
1700  return m_impl.m_value4;
1701  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1702 }
1703 template <>
1704 inline ossia::micrometer_u& distance_u::get()
1705 {
1706  if(m_type == Type5)
1707  return m_impl.m_value5;
1708  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1709 }
1710 template <>
1711 inline ossia::nanometer_u& distance_u::get()
1712 {
1713  if(m_type == Type6)
1714  return m_impl.m_value6;
1715  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1716 }
1717 template <>
1718 inline ossia::picometer_u& distance_u::get()
1719 {
1720  if(m_type == Type7)
1721  return m_impl.m_value7;
1722  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1723 }
1724 template <>
1725 inline ossia::inch_u& distance_u::get()
1726 {
1727  if(m_type == Type8)
1728  return m_impl.m_value8;
1729  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1730 }
1731 template <>
1732 inline ossia::foot_u& distance_u::get()
1733 {
1734  if(m_type == Type9)
1735  return m_impl.m_value9;
1736  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1737 }
1738 template <>
1739 inline ossia::mile_u& distance_u::get()
1740 {
1741  if(m_type == Type10)
1742  return m_impl.m_value10;
1743  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1744 }
1745 template <typename Visitor>
1746 auto apply_nonnull(Visitor&& functor, const distance_u& var)
1747 {
1748  switch(var.m_type)
1749  {
1750  case distance_u::Type::Type0:
1751  return functor(var.m_impl.m_value0);
1752  case distance_u::Type::Type1:
1753  return functor(var.m_impl.m_value1);
1754  case distance_u::Type::Type2:
1755  return functor(var.m_impl.m_value2);
1756  case distance_u::Type::Type3:
1757  return functor(var.m_impl.m_value3);
1758  case distance_u::Type::Type4:
1759  return functor(var.m_impl.m_value4);
1760  case distance_u::Type::Type5:
1761  return functor(var.m_impl.m_value5);
1762  case distance_u::Type::Type6:
1763  return functor(var.m_impl.m_value6);
1764  case distance_u::Type::Type7:
1765  return functor(var.m_impl.m_value7);
1766  case distance_u::Type::Type8:
1767  return functor(var.m_impl.m_value8);
1768  case distance_u::Type::Type9:
1769  return functor(var.m_impl.m_value9);
1770  case distance_u::Type::Type10:
1771  return functor(var.m_impl.m_value10);
1772  default:
1773  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1774  }
1775 }
1776 template <typename Visitor>
1777 auto apply_nonnull(Visitor&& functor, distance_u& var)
1778 {
1779  switch(var.m_type)
1780  {
1781  case distance_u::Type::Type0:
1782  return functor(var.m_impl.m_value0);
1783  case distance_u::Type::Type1:
1784  return functor(var.m_impl.m_value1);
1785  case distance_u::Type::Type2:
1786  return functor(var.m_impl.m_value2);
1787  case distance_u::Type::Type3:
1788  return functor(var.m_impl.m_value3);
1789  case distance_u::Type::Type4:
1790  return functor(var.m_impl.m_value4);
1791  case distance_u::Type::Type5:
1792  return functor(var.m_impl.m_value5);
1793  case distance_u::Type::Type6:
1794  return functor(var.m_impl.m_value6);
1795  case distance_u::Type::Type7:
1796  return functor(var.m_impl.m_value7);
1797  case distance_u::Type::Type8:
1798  return functor(var.m_impl.m_value8);
1799  case distance_u::Type::Type9:
1800  return functor(var.m_impl.m_value9);
1801  case distance_u::Type::Type10:
1802  return functor(var.m_impl.m_value10);
1803  default:
1804  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1805  }
1806 }
1807 template <typename Visitor>
1808 auto apply_nonnull(Visitor&& functor, distance_u&& var)
1809 {
1810  switch(var.m_type)
1811  {
1812  case distance_u::Type::Type0:
1813  return functor(std::move(var.m_impl.m_value0));
1814  case distance_u::Type::Type1:
1815  return functor(std::move(var.m_impl.m_value1));
1816  case distance_u::Type::Type2:
1817  return functor(std::move(var.m_impl.m_value2));
1818  case distance_u::Type::Type3:
1819  return functor(std::move(var.m_impl.m_value3));
1820  case distance_u::Type::Type4:
1821  return functor(std::move(var.m_impl.m_value4));
1822  case distance_u::Type::Type5:
1823  return functor(std::move(var.m_impl.m_value5));
1824  case distance_u::Type::Type6:
1825  return functor(std::move(var.m_impl.m_value6));
1826  case distance_u::Type::Type7:
1827  return functor(std::move(var.m_impl.m_value7));
1828  case distance_u::Type::Type8:
1829  return functor(std::move(var.m_impl.m_value8));
1830  case distance_u::Type::Type9:
1831  return functor(std::move(var.m_impl.m_value9));
1832  case distance_u::Type::Type10:
1833  return functor(std::move(var.m_impl.m_value10));
1834  default:
1835  ossia_do_throw(std::runtime_error, "distance_u: bad type");
1836  }
1837 }
1838 template <typename Visitor>
1839 auto apply(Visitor&& functor, const distance_u& var)
1840 {
1841  switch(var.m_type)
1842  {
1843  case distance_u::Type::Type0:
1844  return functor(var.m_impl.m_value0);
1845  case distance_u::Type::Type1:
1846  return functor(var.m_impl.m_value1);
1847  case distance_u::Type::Type2:
1848  return functor(var.m_impl.m_value2);
1849  case distance_u::Type::Type3:
1850  return functor(var.m_impl.m_value3);
1851  case distance_u::Type::Type4:
1852  return functor(var.m_impl.m_value4);
1853  case distance_u::Type::Type5:
1854  return functor(var.m_impl.m_value5);
1855  case distance_u::Type::Type6:
1856  return functor(var.m_impl.m_value6);
1857  case distance_u::Type::Type7:
1858  return functor(var.m_impl.m_value7);
1859  case distance_u::Type::Type8:
1860  return functor(var.m_impl.m_value8);
1861  case distance_u::Type::Type9:
1862  return functor(var.m_impl.m_value9);
1863  case distance_u::Type::Type10:
1864  return functor(var.m_impl.m_value10);
1865  default:
1866  return functor();
1867  }
1868 }
1869 template <typename Visitor>
1870 auto apply(Visitor&& functor, distance_u& var)
1871 {
1872  switch(var.m_type)
1873  {
1874  case distance_u::Type::Type0:
1875  return functor(var.m_impl.m_value0);
1876  case distance_u::Type::Type1:
1877  return functor(var.m_impl.m_value1);
1878  case distance_u::Type::Type2:
1879  return functor(var.m_impl.m_value2);
1880  case distance_u::Type::Type3:
1881  return functor(var.m_impl.m_value3);
1882  case distance_u::Type::Type4:
1883  return functor(var.m_impl.m_value4);
1884  case distance_u::Type::Type5:
1885  return functor(var.m_impl.m_value5);
1886  case distance_u::Type::Type6:
1887  return functor(var.m_impl.m_value6);
1888  case distance_u::Type::Type7:
1889  return functor(var.m_impl.m_value7);
1890  case distance_u::Type::Type8:
1891  return functor(var.m_impl.m_value8);
1892  case distance_u::Type::Type9:
1893  return functor(var.m_impl.m_value9);
1894  case distance_u::Type::Type10:
1895  return functor(var.m_impl.m_value10);
1896  default:
1897  return functor();
1898  }
1899 }
1900 template <typename Visitor>
1901 auto apply(Visitor&& functor, distance_u&& var)
1902 {
1903  switch(var.m_type)
1904  {
1905  case distance_u::Type::Type0:
1906  return functor(std::move(var.m_impl.m_value0));
1907  case distance_u::Type::Type1:
1908  return functor(std::move(var.m_impl.m_value1));
1909  case distance_u::Type::Type2:
1910  return functor(std::move(var.m_impl.m_value2));
1911  case distance_u::Type::Type3:
1912  return functor(std::move(var.m_impl.m_value3));
1913  case distance_u::Type::Type4:
1914  return functor(std::move(var.m_impl.m_value4));
1915  case distance_u::Type::Type5:
1916  return functor(std::move(var.m_impl.m_value5));
1917  case distance_u::Type::Type6:
1918  return functor(std::move(var.m_impl.m_value6));
1919  case distance_u::Type::Type7:
1920  return functor(std::move(var.m_impl.m_value7));
1921  case distance_u::Type::Type8:
1922  return functor(std::move(var.m_impl.m_value8));
1923  case distance_u::Type::Type9:
1924  return functor(std::move(var.m_impl.m_value9));
1925  case distance_u::Type::Type10:
1926  return functor(std::move(var.m_impl.m_value10));
1927  default:
1928  return functor();
1929  }
1930 }
1931 inline bool operator==(const distance_u& lhs, const distance_u& rhs)
1932 {
1933  return (lhs.m_type == rhs.m_type);
1934 }
1935 inline bool operator!=(const distance_u& lhs, const distance_u& rhs)
1936 {
1937  return (lhs.m_type != rhs.m_type);
1938 }
1939 inline bool operator==(const distance_u& lhs, const ossia::meter_u& rhs)
1940 {
1941  return (lhs.m_type == distance_u::Type::Type0);
1942 }
1943 inline bool operator==(const ossia::meter_u& lhs, const distance_u& rhs)
1944 {
1945  return (rhs.m_type == distance_u::Type::Type0);
1946 }
1947 inline bool operator!=(const distance_u& lhs, const ossia::meter_u& rhs)
1948 {
1949  return (lhs.m_type != distance_u::Type::Type0);
1950 }
1951 inline bool operator!=(const ossia::meter_u& lhs, const distance_u& rhs)
1952 {
1953  return (rhs.m_type != distance_u::Type::Type0);
1954 }
1955 inline bool operator==(const distance_u& lhs, const ossia::kilometer_u& rhs)
1956 {
1957  return (lhs.m_type == distance_u::Type::Type1);
1958 }
1959 inline bool operator==(const ossia::kilometer_u& lhs, const distance_u& rhs)
1960 {
1961  return (rhs.m_type == distance_u::Type::Type1);
1962 }
1963 inline bool operator!=(const distance_u& lhs, const ossia::kilometer_u& rhs)
1964 {
1965  return (lhs.m_type != distance_u::Type::Type1);
1966 }
1967 inline bool operator!=(const ossia::kilometer_u& lhs, const distance_u& rhs)
1968 {
1969  return (rhs.m_type != distance_u::Type::Type1);
1970 }
1971 inline bool operator==(const distance_u& lhs, const ossia::decimeter_u& rhs)
1972 {
1973  return (lhs.m_type == distance_u::Type::Type2);
1974 }
1975 inline bool operator==(const ossia::decimeter_u& lhs, const distance_u& rhs)
1976 {
1977  return (rhs.m_type == distance_u::Type::Type2);
1978 }
1979 inline bool operator!=(const distance_u& lhs, const ossia::decimeter_u& rhs)
1980 {
1981  return (lhs.m_type != distance_u::Type::Type2);
1982 }
1983 inline bool operator!=(const ossia::decimeter_u& lhs, const distance_u& rhs)
1984 {
1985  return (rhs.m_type != distance_u::Type::Type2);
1986 }
1987 inline bool operator==(const distance_u& lhs, const ossia::centimeter_u& rhs)
1988 {
1989  return (lhs.m_type == distance_u::Type::Type3);
1990 }
1991 inline bool operator==(const ossia::centimeter_u& lhs, const distance_u& rhs)
1992 {
1993  return (rhs.m_type == distance_u::Type::Type3);
1994 }
1995 inline bool operator!=(const distance_u& lhs, const ossia::centimeter_u& rhs)
1996 {
1997  return (lhs.m_type != distance_u::Type::Type3);
1998 }
1999 inline bool operator!=(const ossia::centimeter_u& lhs, const distance_u& rhs)
2000 {
2001  return (rhs.m_type != distance_u::Type::Type3);
2002 }
2003 inline bool operator==(const distance_u& lhs, const ossia::millimeter_u& rhs)
2004 {
2005  return (lhs.m_type == distance_u::Type::Type4);
2006 }
2007 inline bool operator==(const ossia::millimeter_u& lhs, const distance_u& rhs)
2008 {
2009  return (rhs.m_type == distance_u::Type::Type4);
2010 }
2011 inline bool operator!=(const distance_u& lhs, const ossia::millimeter_u& rhs)
2012 {
2013  return (lhs.m_type != distance_u::Type::Type4);
2014 }
2015 inline bool operator!=(const ossia::millimeter_u& lhs, const distance_u& rhs)
2016 {
2017  return (rhs.m_type != distance_u::Type::Type4);
2018 }
2019 inline bool operator==(const distance_u& lhs, const ossia::micrometer_u& rhs)
2020 {
2021  return (lhs.m_type == distance_u::Type::Type5);
2022 }
2023 inline bool operator==(const ossia::micrometer_u& lhs, const distance_u& rhs)
2024 {
2025  return (rhs.m_type == distance_u::Type::Type5);
2026 }
2027 inline bool operator!=(const distance_u& lhs, const ossia::micrometer_u& rhs)
2028 {
2029  return (lhs.m_type != distance_u::Type::Type5);
2030 }
2031 inline bool operator!=(const ossia::micrometer_u& lhs, const distance_u& rhs)
2032 {
2033  return (rhs.m_type != distance_u::Type::Type5);
2034 }
2035 inline bool operator==(const distance_u& lhs, const ossia::nanometer_u& rhs)
2036 {
2037  return (lhs.m_type == distance_u::Type::Type6);
2038 }
2039 inline bool operator==(const ossia::nanometer_u& lhs, const distance_u& rhs)
2040 {
2041  return (rhs.m_type == distance_u::Type::Type6);
2042 }
2043 inline bool operator!=(const distance_u& lhs, const ossia::nanometer_u& rhs)
2044 {
2045  return (lhs.m_type != distance_u::Type::Type6);
2046 }
2047 inline bool operator!=(const ossia::nanometer_u& lhs, const distance_u& rhs)
2048 {
2049  return (rhs.m_type != distance_u::Type::Type6);
2050 }
2051 inline bool operator==(const distance_u& lhs, const ossia::picometer_u& rhs)
2052 {
2053  return (lhs.m_type == distance_u::Type::Type7);
2054 }
2055 inline bool operator==(const ossia::picometer_u& lhs, const distance_u& rhs)
2056 {
2057  return (rhs.m_type == distance_u::Type::Type7);
2058 }
2059 inline bool operator!=(const distance_u& lhs, const ossia::picometer_u& rhs)
2060 {
2061  return (lhs.m_type != distance_u::Type::Type7);
2062 }
2063 inline bool operator!=(const ossia::picometer_u& lhs, const distance_u& rhs)
2064 {
2065  return (rhs.m_type != distance_u::Type::Type7);
2066 }
2067 inline bool operator==(const distance_u& lhs, const ossia::inch_u& rhs)
2068 {
2069  return (lhs.m_type == distance_u::Type::Type8);
2070 }
2071 inline bool operator==(const ossia::inch_u& lhs, const distance_u& rhs)
2072 {
2073  return (rhs.m_type == distance_u::Type::Type8);
2074 }
2075 inline bool operator!=(const distance_u& lhs, const ossia::inch_u& rhs)
2076 {
2077  return (lhs.m_type != distance_u::Type::Type8);
2078 }
2079 inline bool operator!=(const ossia::inch_u& lhs, const distance_u& rhs)
2080 {
2081  return (rhs.m_type != distance_u::Type::Type8);
2082 }
2083 inline bool operator==(const distance_u& lhs, const ossia::foot_u& rhs)
2084 {
2085  return (lhs.m_type == distance_u::Type::Type9);
2086 }
2087 inline bool operator==(const ossia::foot_u& lhs, const distance_u& rhs)
2088 {
2089  return (rhs.m_type == distance_u::Type::Type9);
2090 }
2091 inline bool operator!=(const distance_u& lhs, const ossia::foot_u& rhs)
2092 {
2093  return (lhs.m_type != distance_u::Type::Type9);
2094 }
2095 inline bool operator!=(const ossia::foot_u& lhs, const distance_u& rhs)
2096 {
2097  return (rhs.m_type != distance_u::Type::Type9);
2098 }
2099 inline bool operator==(const distance_u& lhs, const ossia::mile_u& rhs)
2100 {
2101  return (lhs.m_type == distance_u::Type::Type10);
2102 }
2103 inline bool operator==(const ossia::mile_u& lhs, const distance_u& rhs)
2104 {
2105  return (rhs.m_type == distance_u::Type::Type10);
2106 }
2107 inline bool operator!=(const distance_u& lhs, const ossia::mile_u& rhs)
2108 {
2109  return (lhs.m_type != distance_u::Type::Type10);
2110 }
2111 inline bool operator!=(const ossia::mile_u& lhs, const distance_u& rhs)
2112 {
2113  return (rhs.m_type != distance_u::Type::Type10);
2114 }
2115 struct gain_u
2116 {
2117 public:
2118  struct dummy_t
2119  {
2120  };
2121  union Impl
2122  {
2123  ossia::linear_u m_value0;
2124 
2125  ossia::midigain_u m_value1;
2126 
2127  ossia::decibel_u m_value2;
2128 
2129  ossia::decibel_raw_u m_value3;
2130 
2131  dummy_t m_dummy;
2132  Impl()
2133  : m_dummy{}
2134  {
2135  }
2136  ~Impl() = default;
2137  };
2138 
2139  enum Type : int8_t
2140  {
2141  Type0,
2142  Type1,
2143  Type2,
2144  Type3,
2146  };
2147 
2148  Impl m_impl;
2149  Type m_type;
2150 
2151 public:
2152  static const constexpr auto npos = Npos;
2153  int which() const { return m_type; }
2154 
2155  operator bool() const { return m_type != npos; }
2156  template <typename T>
2157  const T* target() const;
2158  template <typename T>
2159  T* target();
2160  template <typename T>
2161  const T& get() const;
2162  template <typename T>
2163  T& get();
2164 
2165  template <typename T>
2166  static Type matching_type();
2167  gain_u()
2168  : m_type{Npos}
2169  {
2170  }
2171  ~gain_u() = default;
2172  gain_u(ossia::linear_u v)
2173  : m_type{Type0}
2174  {
2175  new(&m_impl.m_value0) ossia::linear_u{v};
2176  }
2177  gain_u(ossia::midigain_u v)
2178  : m_type{Type1}
2179  {
2180  new(&m_impl.m_value1) ossia::midigain_u{v};
2181  }
2182  gain_u(ossia::decibel_u v)
2183  : m_type{Type2}
2184  {
2185  new(&m_impl.m_value2) ossia::decibel_u{v};
2186  }
2187  gain_u(ossia::decibel_raw_u v)
2188  : m_type{Type3}
2189  {
2190  new(&m_impl.m_value3) ossia::decibel_raw_u{v};
2191  }
2192  gain_u(const gain_u& other)
2193  : m_type{other.m_type}
2194  {
2195  switch(m_type)
2196  {
2197  case Type::Type0:
2198  new(&m_impl.m_value0) ossia::linear_u{other.m_impl.m_value0};
2199  break;
2200  case Type::Type1:
2201  new(&m_impl.m_value1) ossia::midigain_u{other.m_impl.m_value1};
2202  break;
2203  case Type::Type2:
2204  new(&m_impl.m_value2) ossia::decibel_u{other.m_impl.m_value2};
2205  break;
2206  case Type::Type3:
2207  new(&m_impl.m_value3) ossia::decibel_raw_u{other.m_impl.m_value3};
2208  break;
2209  default:
2210  break;
2211  }
2212  }
2213  gain_u(gain_u&& other) noexcept
2214  : m_type{other.m_type}
2215  {
2216  switch(m_type)
2217  {
2218  case Type::Type0:
2219  new(&m_impl.m_value0) ossia::linear_u{std::move(other.m_impl.m_value0)};
2220  break;
2221  case Type::Type1:
2222  new(&m_impl.m_value1) ossia::midigain_u{std::move(other.m_impl.m_value1)};
2223  break;
2224  case Type::Type2:
2225  new(&m_impl.m_value2) ossia::decibel_u{std::move(other.m_impl.m_value2)};
2226  break;
2227  case Type::Type3:
2228  new(&m_impl.m_value3) ossia::decibel_raw_u{std::move(other.m_impl.m_value3)};
2229  break;
2230  default:
2231  break;
2232  }
2233  }
2234  gain_u& operator=(const gain_u& other)
2235  {
2236 
2237  m_type = other.m_type;
2238  switch(m_type)
2239  {
2240  case Type::Type0:
2241  new(&m_impl.m_value0) ossia::linear_u{other.m_impl.m_value0};
2242  break;
2243  case Type::Type1:
2244  new(&m_impl.m_value1) ossia::midigain_u{other.m_impl.m_value1};
2245  break;
2246  case Type::Type2:
2247  new(&m_impl.m_value2) ossia::decibel_u{other.m_impl.m_value2};
2248  break;
2249  case Type::Type3:
2250  new(&m_impl.m_value3) ossia::decibel_raw_u{other.m_impl.m_value3};
2251  break;
2252  default:
2253  break;
2254  }
2255  return *this;
2256  }
2257  gain_u& operator=(gain_u&& other) noexcept
2258  {
2259 
2260  m_type = other.m_type;
2261  switch(m_type)
2262  {
2263  case Type::Type0:
2264  new(&m_impl.m_value0) ossia::linear_u{std::move(other.m_impl.m_value0)};
2265  break;
2266  case Type::Type1:
2267  new(&m_impl.m_value1) ossia::midigain_u{std::move(other.m_impl.m_value1)};
2268  break;
2269  case Type::Type2:
2270  new(&m_impl.m_value2) ossia::decibel_u{std::move(other.m_impl.m_value2)};
2271  break;
2272  case Type::Type3:
2273  new(&m_impl.m_value3) ossia::decibel_raw_u{std::move(other.m_impl.m_value3)};
2274  break;
2275  default:
2276  break;
2277  }
2278  return *this;
2279  }
2280 };
2281 template <>
2282 inline const ossia::linear_u* gain_u::target() const
2283 {
2284  if(m_type == Type0)
2285  return &m_impl.m_value0;
2286  return nullptr;
2287 }
2288 template <>
2289 inline const ossia::midigain_u* gain_u::target() const
2290 {
2291  if(m_type == Type1)
2292  return &m_impl.m_value1;
2293  return nullptr;
2294 }
2295 template <>
2296 inline const ossia::decibel_u* gain_u::target() const
2297 {
2298  if(m_type == Type2)
2299  return &m_impl.m_value2;
2300  return nullptr;
2301 }
2302 template <>
2303 inline const ossia::decibel_raw_u* gain_u::target() const
2304 {
2305  if(m_type == Type3)
2306  return &m_impl.m_value3;
2307  return nullptr;
2308 }
2309 template <>
2310 inline ossia::linear_u* gain_u::target()
2311 {
2312  if(m_type == Type0)
2313  return &m_impl.m_value0;
2314  return nullptr;
2315 }
2316 template <>
2317 inline ossia::midigain_u* gain_u::target()
2318 {
2319  if(m_type == Type1)
2320  return &m_impl.m_value1;
2321  return nullptr;
2322 }
2323 template <>
2324 inline ossia::decibel_u* gain_u::target()
2325 {
2326  if(m_type == Type2)
2327  return &m_impl.m_value2;
2328  return nullptr;
2329 }
2330 template <>
2331 inline ossia::decibel_raw_u* gain_u::target()
2332 {
2333  if(m_type == Type3)
2334  return &m_impl.m_value3;
2335  return nullptr;
2336 }
2337 template <>
2338 inline const ossia::linear_u& gain_u::get() const
2339 {
2340  if(m_type == Type0)
2341  return m_impl.m_value0;
2342  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2343 }
2344 template <>
2345 inline const ossia::midigain_u& gain_u::get() const
2346 {
2347  if(m_type == Type1)
2348  return m_impl.m_value1;
2349  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2350 }
2351 template <>
2352 inline const ossia::decibel_u& gain_u::get() const
2353 {
2354  if(m_type == Type2)
2355  return m_impl.m_value2;
2356  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2357 }
2358 template <>
2359 inline const ossia::decibel_raw_u& gain_u::get() const
2360 {
2361  if(m_type == Type3)
2362  return m_impl.m_value3;
2363  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2364 }
2365 template <>
2366 inline ossia::linear_u& gain_u::get()
2367 {
2368  if(m_type == Type0)
2369  return m_impl.m_value0;
2370  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2371 }
2372 template <>
2373 inline ossia::midigain_u& gain_u::get()
2374 {
2375  if(m_type == Type1)
2376  return m_impl.m_value1;
2377  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2378 }
2379 template <>
2380 inline ossia::decibel_u& gain_u::get()
2381 {
2382  if(m_type == Type2)
2383  return m_impl.m_value2;
2384  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2385 }
2386 template <>
2387 inline ossia::decibel_raw_u& gain_u::get()
2388 {
2389  if(m_type == Type3)
2390  return m_impl.m_value3;
2391  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2392 }
2393 template <typename Visitor>
2394 auto apply_nonnull(Visitor&& functor, const gain_u& var)
2395 {
2396  switch(var.m_type)
2397  {
2398  case gain_u::Type::Type0:
2399  return functor(var.m_impl.m_value0);
2400  case gain_u::Type::Type1:
2401  return functor(var.m_impl.m_value1);
2402  case gain_u::Type::Type2:
2403  return functor(var.m_impl.m_value2);
2404  case gain_u::Type::Type3:
2405  return functor(var.m_impl.m_value3);
2406  default:
2407  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2408  }
2409 }
2410 template <typename Visitor>
2411 auto apply_nonnull(Visitor&& functor, gain_u& var)
2412 {
2413  switch(var.m_type)
2414  {
2415  case gain_u::Type::Type0:
2416  return functor(var.m_impl.m_value0);
2417  case gain_u::Type::Type1:
2418  return functor(var.m_impl.m_value1);
2419  case gain_u::Type::Type2:
2420  return functor(var.m_impl.m_value2);
2421  case gain_u::Type::Type3:
2422  return functor(var.m_impl.m_value3);
2423  default:
2424  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2425  }
2426 }
2427 template <typename Visitor>
2428 auto apply_nonnull(Visitor&& functor, gain_u&& var)
2429 {
2430  switch(var.m_type)
2431  {
2432  case gain_u::Type::Type0:
2433  return functor(std::move(var.m_impl.m_value0));
2434  case gain_u::Type::Type1:
2435  return functor(std::move(var.m_impl.m_value1));
2436  case gain_u::Type::Type2:
2437  return functor(std::move(var.m_impl.m_value2));
2438  case gain_u::Type::Type3:
2439  return functor(std::move(var.m_impl.m_value3));
2440  default:
2441  ossia_do_throw(std::runtime_error, "gain_u: bad type");
2442  }
2443 }
2444 template <typename Visitor>
2445 auto apply(Visitor&& functor, const gain_u& var)
2446 {
2447  switch(var.m_type)
2448  {
2449  case gain_u::Type::Type0:
2450  return functor(var.m_impl.m_value0);
2451  case gain_u::Type::Type1:
2452  return functor(var.m_impl.m_value1);
2453  case gain_u::Type::Type2:
2454  return functor(var.m_impl.m_value2);
2455  case gain_u::Type::Type3:
2456  return functor(var.m_impl.m_value3);
2457  default:
2458  return functor();
2459  }
2460 }
2461 template <typename Visitor>
2462 auto apply(Visitor&& functor, gain_u& var)
2463 {
2464  switch(var.m_type)
2465  {
2466  case gain_u::Type::Type0:
2467  return functor(var.m_impl.m_value0);
2468  case gain_u::Type::Type1:
2469  return functor(var.m_impl.m_value1);
2470  case gain_u::Type::Type2:
2471  return functor(var.m_impl.m_value2);
2472  case gain_u::Type::Type3:
2473  return functor(var.m_impl.m_value3);
2474  default:
2475  return functor();
2476  }
2477 }
2478 template <typename Visitor>
2479 auto apply(Visitor&& functor, gain_u&& var)
2480 {
2481  switch(var.m_type)
2482  {
2483  case gain_u::Type::Type0:
2484  return functor(std::move(var.m_impl.m_value0));
2485  case gain_u::Type::Type1:
2486  return functor(std::move(var.m_impl.m_value1));
2487  case gain_u::Type::Type2:
2488  return functor(std::move(var.m_impl.m_value2));
2489  case gain_u::Type::Type3:
2490  return functor(std::move(var.m_impl.m_value3));
2491  default:
2492  return functor();
2493  }
2494 }
2495 inline bool operator==(const gain_u& lhs, const gain_u& rhs)
2496 {
2497  return (lhs.m_type == rhs.m_type);
2498 }
2499 inline bool operator!=(const gain_u& lhs, const gain_u& rhs)
2500 {
2501  return (lhs.m_type != rhs.m_type);
2502 }
2503 inline bool operator==(const gain_u& lhs, const ossia::linear_u& rhs)
2504 {
2505  return (lhs.m_type == gain_u::Type::Type0);
2506 }
2507 inline bool operator==(const ossia::linear_u& lhs, const gain_u& rhs)
2508 {
2509  return (rhs.m_type == gain_u::Type::Type0);
2510 }
2511 inline bool operator!=(const gain_u& lhs, const ossia::linear_u& rhs)
2512 {
2513  return (lhs.m_type != gain_u::Type::Type0);
2514 }
2515 inline bool operator!=(const ossia::linear_u& lhs, const gain_u& rhs)
2516 {
2517  return (rhs.m_type != gain_u::Type::Type0);
2518 }
2519 inline bool operator==(const gain_u& lhs, const ossia::midigain_u& rhs)
2520 {
2521  return (lhs.m_type == gain_u::Type::Type1);
2522 }
2523 inline bool operator==(const ossia::midigain_u& lhs, const gain_u& rhs)
2524 {
2525  return (rhs.m_type == gain_u::Type::Type1);
2526 }
2527 inline bool operator!=(const gain_u& lhs, const ossia::midigain_u& rhs)
2528 {
2529  return (lhs.m_type != gain_u::Type::Type1);
2530 }
2531 inline bool operator!=(const ossia::midigain_u& lhs, const gain_u& rhs)
2532 {
2533  return (rhs.m_type != gain_u::Type::Type1);
2534 }
2535 inline bool operator==(const gain_u& lhs, const ossia::decibel_u& rhs)
2536 {
2537  return (lhs.m_type == gain_u::Type::Type2);
2538 }
2539 inline bool operator==(const ossia::decibel_u& lhs, const gain_u& rhs)
2540 {
2541  return (rhs.m_type == gain_u::Type::Type2);
2542 }
2543 inline bool operator!=(const gain_u& lhs, const ossia::decibel_u& rhs)
2544 {
2545  return (lhs.m_type != gain_u::Type::Type2);
2546 }
2547 inline bool operator!=(const ossia::decibel_u& lhs, const gain_u& rhs)
2548 {
2549  return (rhs.m_type != gain_u::Type::Type2);
2550 }
2551 inline bool operator==(const gain_u& lhs, const ossia::decibel_raw_u& rhs)
2552 {
2553  return (lhs.m_type == gain_u::Type::Type3);
2554 }
2555 inline bool operator==(const ossia::decibel_raw_u& lhs, const gain_u& rhs)
2556 {
2557  return (rhs.m_type == gain_u::Type::Type3);
2558 }
2559 inline bool operator!=(const gain_u& lhs, const ossia::decibel_raw_u& rhs)
2560 {
2561  return (lhs.m_type != gain_u::Type::Type3);
2562 }
2563 inline bool operator!=(const ossia::decibel_raw_u& lhs, const gain_u& rhs)
2564 {
2565  return (rhs.m_type != gain_u::Type::Type3);
2566 }
2567 struct orientation_u
2568 {
2569 public:
2570  struct dummy_t
2571  {
2572  };
2573  union Impl
2574  {
2575  ossia::quaternion_u m_value0;
2576 
2577  ossia::euler_u m_value1;
2578 
2579  ossia::axis_u m_value2;
2580 
2581  dummy_t m_dummy;
2582  Impl()
2583  : m_dummy{}
2584  {
2585  }
2586  ~Impl() = default;
2587  };
2588 
2589  enum Type : int8_t
2590  {
2591  Type0,
2592  Type1,
2593  Type2,
2595  };
2596 
2597  Impl m_impl;
2598  Type m_type;
2599 
2600 public:
2601  static const constexpr auto npos = Npos;
2602  int which() const { return m_type; }
2603 
2604  operator bool() const { return m_type != npos; }
2605  template <typename T>
2606  const T* target() const;
2607  template <typename T>
2608  T* target();
2609  template <typename T>
2610  const T& get() const;
2611  template <typename T>
2612  T& get();
2613 
2614  template <typename T>
2615  static Type matching_type();
2616  orientation_u()
2617  : m_type{Npos}
2618  {
2619  }
2620  ~orientation_u() = default;
2621  orientation_u(ossia::quaternion_u v)
2622  : m_type{Type0}
2623  {
2624  new(&m_impl.m_value0) ossia::quaternion_u{v};
2625  }
2626  orientation_u(ossia::euler_u v)
2627  : m_type{Type1}
2628  {
2629  new(&m_impl.m_value1) ossia::euler_u{v};
2630  }
2631  orientation_u(ossia::axis_u v)
2632  : m_type{Type2}
2633  {
2634  new(&m_impl.m_value2) ossia::axis_u{v};
2635  }
2636  orientation_u(const orientation_u& other)
2637  : m_type{other.m_type}
2638  {
2639  switch(m_type)
2640  {
2641  case Type::Type0:
2642  new(&m_impl.m_value0) ossia::quaternion_u{other.m_impl.m_value0};
2643  break;
2644  case Type::Type1:
2645  new(&m_impl.m_value1) ossia::euler_u{other.m_impl.m_value1};
2646  break;
2647  case Type::Type2:
2648  new(&m_impl.m_value2) ossia::axis_u{other.m_impl.m_value2};
2649  break;
2650  default:
2651  break;
2652  }
2653  }
2654  orientation_u(orientation_u&& other) noexcept
2655  : m_type{other.m_type}
2656  {
2657  switch(m_type)
2658  {
2659  case Type::Type0:
2660  new(&m_impl.m_value0) ossia::quaternion_u{std::move(other.m_impl.m_value0)};
2661  break;
2662  case Type::Type1:
2663  new(&m_impl.m_value1) ossia::euler_u{std::move(other.m_impl.m_value1)};
2664  break;
2665  case Type::Type2:
2666  new(&m_impl.m_value2) ossia::axis_u{std::move(other.m_impl.m_value2)};
2667  break;
2668  default:
2669  break;
2670  }
2671  }
2672  orientation_u& operator=(const orientation_u& other)
2673  {
2674 
2675  m_type = other.m_type;
2676  switch(m_type)
2677  {
2678  case Type::Type0:
2679  new(&m_impl.m_value0) ossia::quaternion_u{other.m_impl.m_value0};
2680  break;
2681  case Type::Type1:
2682  new(&m_impl.m_value1) ossia::euler_u{other.m_impl.m_value1};
2683  break;
2684  case Type::Type2:
2685  new(&m_impl.m_value2) ossia::axis_u{other.m_impl.m_value2};
2686  break;
2687  default:
2688  break;
2689  }
2690  return *this;
2691  }
2692  orientation_u& operator=(orientation_u&& other) noexcept
2693  {
2694 
2695  m_type = other.m_type;
2696  switch(m_type)
2697  {
2698  case Type::Type0:
2699  new(&m_impl.m_value0) ossia::quaternion_u{std::move(other.m_impl.m_value0)};
2700  break;
2701  case Type::Type1:
2702  new(&m_impl.m_value1) ossia::euler_u{std::move(other.m_impl.m_value1)};
2703  break;
2704  case Type::Type2:
2705  new(&m_impl.m_value2) ossia::axis_u{std::move(other.m_impl.m_value2)};
2706  break;
2707  default:
2708  break;
2709  }
2710  return *this;
2711  }
2712 };
2713 template <>
2714 inline const ossia::quaternion_u* orientation_u::target() const
2715 {
2716  if(m_type == Type0)
2717  return &m_impl.m_value0;
2718  return nullptr;
2719 }
2720 template <>
2721 inline const ossia::euler_u* orientation_u::target() const
2722 {
2723  if(m_type == Type1)
2724  return &m_impl.m_value1;
2725  return nullptr;
2726 }
2727 template <>
2728 inline const ossia::axis_u* orientation_u::target() const
2729 {
2730  if(m_type == Type2)
2731  return &m_impl.m_value2;
2732  return nullptr;
2733 }
2734 template <>
2735 inline ossia::quaternion_u* orientation_u::target()
2736 {
2737  if(m_type == Type0)
2738  return &m_impl.m_value0;
2739  return nullptr;
2740 }
2741 template <>
2742 inline ossia::euler_u* orientation_u::target()
2743 {
2744  if(m_type == Type1)
2745  return &m_impl.m_value1;
2746  return nullptr;
2747 }
2748 template <>
2749 inline ossia::axis_u* orientation_u::target()
2750 {
2751  if(m_type == Type2)
2752  return &m_impl.m_value2;
2753  return nullptr;
2754 }
2755 template <>
2756 inline const ossia::quaternion_u& orientation_u::get() const
2757 {
2758  if(m_type == Type0)
2759  return m_impl.m_value0;
2760  ossia_do_throw(std::runtime_error, "orientation_u: bad type");
2761 }
2762 template <>
2763 inline const ossia::euler_u& orientation_u::get() const
2764 {
2765  if(m_type == Type1)
2766  return m_impl.m_value1;
2767  ossia_do_throw(std::runtime_error, "orientation_u: bad type");
2768 }
2769 template <>
2770 inline const ossia::axis_u& orientation_u::get() const
2771 {
2772  if(m_type == Type2)
2773  return m_impl.m_value2;
2774  ossia_do_throw(std::runtime_error, "orientation_u: bad type");
2775 }
2776 template <>
2777 inline ossia::quaternion_u& orientation_u::get()
2778 {
2779  if(m_type == Type0)
2780  return m_impl.m_value0;
2781  ossia_do_throw(std::runtime_error, "orientation_u: bad type");
2782 }
2783 template <>
2784 inline ossia::euler_u& orientation_u::get()
2785 {
2786  if(m_type == Type1)
2787  return m_impl.m_value1;
2788  ossia_do_throw(std::runtime_error, "orientation_u: bad type");
2789 }
2790 template <>
2791 inline ossia::axis_u& orientation_u::get()
2792 {
2793  if(m_type == Type2)
2794  return m_impl.m_value2;
2795  ossia_do_throw(std::runtime_error, "orientation_u: bad type");
2796 }
2797 template <typename Visitor>
2798 auto apply_nonnull(Visitor&& functor, const orientation_u& var)
2799 {
2800  switch(var.m_type)
2801  {
2802  case orientation_u::Type::Type0:
2803  return functor(var.m_impl.m_value0);
2804  case orientation_u::Type::Type1:
2805  return functor(var.m_impl.m_value1);
2806  case orientation_u::Type::Type2:
2807  return functor(var.m_impl.m_value2);
2808  default:
2809  ossia_do_throw(std::runtime_error, "orientation_u: bad type");
2810  }
2811 }
2812 template <typename Visitor>
2813 auto apply_nonnull(Visitor&& functor, orientation_u& var)
2814 {
2815  switch(var.m_type)
2816  {
2817  case orientation_u::Type::Type0:
2818  return functor(var.m_impl.m_value0);
2819  case orientation_u::Type::Type1:
2820  return functor(var.m_impl.m_value1);
2821  case orientation_u::Type::Type2:
2822  return functor(var.m_impl.m_value2);
2823  default:
2824  ossia_do_throw(std::runtime_error, "orientation_u: bad type");
2825  }
2826 }
2827 template <typename Visitor>
2828 auto apply_nonnull(Visitor&& functor, orientation_u&& var)
2829 {
2830  switch(var.m_type)
2831  {
2832  case orientation_u::Type::Type0:
2833  return functor(std::move(var.m_impl.m_value0));
2834  case orientation_u::Type::Type1:
2835  return functor(std::move(var.m_impl.m_value1));
2836  case orientation_u::Type::Type2:
2837  return functor(std::move(var.m_impl.m_value2));
2838  default:
2839  ossia_do_throw(std::runtime_error, "orientation_u: bad type");
2840  }
2841 }
2842 template <typename Visitor>
2843 auto apply(Visitor&& functor, const orientation_u& var)
2844 {
2845  switch(var.m_type)
2846  {
2847  case orientation_u::Type::Type0:
2848  return functor(var.m_impl.m_value0);
2849  case orientation_u::Type::Type1:
2850  return functor(var.m_impl.m_value1);
2851  case orientation_u::Type::Type2:
2852  return functor(var.m_impl.m_value2);
2853  default:
2854  return functor();
2855  }
2856 }
2857 template <typename Visitor>
2858 auto apply(Visitor&& functor, orientation_u& var)
2859 {
2860  switch(var.m_type)
2861  {
2862  case orientation_u::Type::Type0:
2863  return functor(var.m_impl.m_value0);
2864  case orientation_u::Type::Type1:
2865  return functor(var.m_impl.m_value1);
2866  case orientation_u::Type::Type2:
2867  return functor(var.m_impl.m_value2);
2868  default:
2869  return functor();
2870  }
2871 }
2872 template <typename Visitor>
2873 auto apply(Visitor&& functor, orientation_u&& var)
2874 {
2875  switch(var.m_type)
2876  {
2877  case orientation_u::Type::Type0:
2878  return functor(std::move(var.m_impl.m_value0));
2879  case orientation_u::Type::Type1:
2880  return functor(std::move(var.m_impl.m_value1));
2881  case orientation_u::Type::Type2:
2882  return functor(std::move(var.m_impl.m_value2));
2883  default:
2884  return functor();
2885  }
2886 }
2887 inline bool operator==(const orientation_u& lhs, const orientation_u& rhs)
2888 {
2889  return (lhs.m_type == rhs.m_type);
2890 }
2891 inline bool operator!=(const orientation_u& lhs, const orientation_u& rhs)
2892 {
2893  return (lhs.m_type != rhs.m_type);
2894 }
2895 inline bool operator==(const orientation_u& lhs, const ossia::quaternion_u& rhs)
2896 {
2897  return (lhs.m_type == orientation_u::Type::Type0);
2898 }
2899 inline bool operator==(const ossia::quaternion_u& lhs, const orientation_u& rhs)
2900 {
2901  return (rhs.m_type == orientation_u::Type::Type0);
2902 }
2903 inline bool operator!=(const orientation_u& lhs, const ossia::quaternion_u& rhs)
2904 {
2905  return (lhs.m_type != orientation_u::Type::Type0);
2906 }
2907 inline bool operator!=(const ossia::quaternion_u& lhs, const orientation_u& rhs)
2908 {
2909  return (rhs.m_type != orientation_u::Type::Type0);
2910 }
2911 inline bool operator==(const orientation_u& lhs, const ossia::euler_u& rhs)
2912 {
2913  return (lhs.m_type == orientation_u::Type::Type1);
2914 }
2915 inline bool operator==(const ossia::euler_u& lhs, const orientation_u& rhs)
2916 {
2917  return (rhs.m_type == orientation_u::Type::Type1);
2918 }
2919 inline bool operator!=(const orientation_u& lhs, const ossia::euler_u& rhs)
2920 {
2921  return (lhs.m_type != orientation_u::Type::Type1);
2922 }
2923 inline bool operator!=(const ossia::euler_u& lhs, const orientation_u& rhs)
2924 {
2925  return (rhs.m_type != orientation_u::Type::Type1);
2926 }
2927 inline bool operator==(const orientation_u& lhs, const ossia::axis_u& rhs)
2928 {
2929  return (lhs.m_type == orientation_u::Type::Type2);
2930 }
2931 inline bool operator==(const ossia::axis_u& lhs, const orientation_u& rhs)
2932 {
2933  return (rhs.m_type == orientation_u::Type::Type2);
2934 }
2935 inline bool operator!=(const orientation_u& lhs, const ossia::axis_u& rhs)
2936 {
2937  return (lhs.m_type != orientation_u::Type::Type2);
2938 }
2939 inline bool operator!=(const ossia::axis_u& lhs, const orientation_u& rhs)
2940 {
2941  return (rhs.m_type != orientation_u::Type::Type2);
2942 }
2943 struct position_u
2944 {
2945 public:
2946  struct dummy_t
2947  {
2948  };
2949  union Impl
2950  {
2951  ossia::cartesian_3d_u m_value0;
2952 
2953  ossia::cartesian_2d_u m_value1;
2954 
2955  ossia::spherical_u m_value2;
2956 
2957  ossia::polar_u m_value3;
2958 
2959  ossia::aed_u m_value4;
2960 
2961  ossia::ad_u m_value5;
2962 
2963  ossia::opengl_u m_value6;
2964 
2965  ossia::cylindrical_u m_value7;
2966 
2967  ossia::azd_u m_value8;
2968 
2969  dummy_t m_dummy;
2970  Impl()
2971  : m_dummy{}
2972  {
2973  }
2974  ~Impl() = default;
2975  };
2976 
2977  enum Type : int8_t
2978  {
2979  Type0,
2980  Type1,
2981  Type2,
2982  Type3,
2983  Type4,
2984  Type5,
2985  Type6,
2986  Type7,
2987  Type8,
2989  };
2990 
2991  Impl m_impl;
2992  Type m_type;
2993 
2994 public:
2995  static const constexpr auto npos = Npos;
2996  int which() const { return m_type; }
2997 
2998  operator bool() const { return m_type != npos; }
2999  template <typename T>
3000  const T* target() const;
3001  template <typename T>
3002  T* target();
3003  template <typename T>
3004  const T& get() const;
3005  template <typename T>
3006  T& get();
3007 
3008  template <typename T>
3009  static Type matching_type();
3010  position_u()
3011  : m_type{Npos}
3012  {
3013  }
3014  ~position_u() = default;
3015  position_u(ossia::cartesian_3d_u v)
3016  : m_type{Type0}
3017  {
3018  new(&m_impl.m_value0) ossia::cartesian_3d_u{v};
3019  }
3020  position_u(ossia::cartesian_2d_u v)
3021  : m_type{Type1}
3022  {
3023  new(&m_impl.m_value1) ossia::cartesian_2d_u{v};
3024  }
3025  position_u(ossia::spherical_u v)
3026  : m_type{Type2}
3027  {
3028  new(&m_impl.m_value2) ossia::spherical_u{v};
3029  }
3030  position_u(ossia::polar_u v)
3031  : m_type{Type3}
3032  {
3033  new(&m_impl.m_value3) ossia::polar_u{v};
3034  }
3035  position_u(ossia::aed_u v)
3036  : m_type{Type4}
3037  {
3038  new(&m_impl.m_value4) ossia::aed_u{v};
3039  }
3040  position_u(ossia::ad_u v)
3041  : m_type{Type5}
3042  {
3043  new(&m_impl.m_value5) ossia::ad_u{v};
3044  }
3045  position_u(ossia::opengl_u v)
3046  : m_type{Type6}
3047  {
3048  new(&m_impl.m_value6) ossia::opengl_u{v};
3049  }
3050  position_u(ossia::cylindrical_u v)
3051  : m_type{Type7}
3052  {
3053  new(&m_impl.m_value7) ossia::cylindrical_u{v};
3054  }
3055  position_u(ossia::azd_u v)
3056  : m_type{Type8}
3057  {
3058  new(&m_impl.m_value8) ossia::azd_u{v};
3059  }
3060  position_u(const position_u& other)
3061  : m_type{other.m_type}
3062  {
3063  switch(m_type)
3064  {
3065  case Type::Type0:
3066  new(&m_impl.m_value0) ossia::cartesian_3d_u{other.m_impl.m_value0};
3067  break;
3068  case Type::Type1:
3069  new(&m_impl.m_value1) ossia::cartesian_2d_u{other.m_impl.m_value1};
3070  break;
3071  case Type::Type2:
3072  new(&m_impl.m_value2) ossia::spherical_u{other.m_impl.m_value2};
3073  break;
3074  case Type::Type3:
3075  new(&m_impl.m_value3) ossia::polar_u{other.m_impl.m_value3};
3076  break;
3077  case Type::Type4:
3078  new(&m_impl.m_value4) ossia::aed_u{other.m_impl.m_value4};
3079  break;
3080  case Type::Type5:
3081  new(&m_impl.m_value5) ossia::ad_u{other.m_impl.m_value5};
3082  break;
3083  case Type::Type6:
3084  new(&m_impl.m_value6) ossia::opengl_u{other.m_impl.m_value6};
3085  break;
3086  case Type::Type7:
3087  new(&m_impl.m_value7) ossia::cylindrical_u{other.m_impl.m_value7};
3088  break;
3089  case Type::Type8:
3090  new(&m_impl.m_value8) ossia::azd_u{other.m_impl.m_value8};
3091  break;
3092  default:
3093  break;
3094  }
3095  }
3096  position_u(position_u&& other) noexcept
3097  : m_type{other.m_type}
3098  {
3099  switch(m_type)
3100  {
3101  case Type::Type0:
3102  new(&m_impl.m_value0) ossia::cartesian_3d_u{std::move(other.m_impl.m_value0)};
3103  break;
3104  case Type::Type1:
3105  new(&m_impl.m_value1) ossia::cartesian_2d_u{std::move(other.m_impl.m_value1)};
3106  break;
3107  case Type::Type2:
3108  new(&m_impl.m_value2) ossia::spherical_u{std::move(other.m_impl.m_value2)};
3109  break;
3110  case Type::Type3:
3111  new(&m_impl.m_value3) ossia::polar_u{std::move(other.m_impl.m_value3)};
3112  break;
3113  case Type::Type4:
3114  new(&m_impl.m_value4) ossia::aed_u{std::move(other.m_impl.m_value4)};
3115  break;
3116  case Type::Type5:
3117  new(&m_impl.m_value5) ossia::ad_u{std::move(other.m_impl.m_value5)};
3118  break;
3119  case Type::Type6:
3120  new(&m_impl.m_value6) ossia::opengl_u{std::move(other.m_impl.m_value6)};
3121  break;
3122  case Type::Type7:
3123  new(&m_impl.m_value7) ossia::cylindrical_u{std::move(other.m_impl.m_value7)};
3124  break;
3125  case Type::Type8:
3126  new(&m_impl.m_value8) ossia::azd_u{std::move(other.m_impl.m_value8)};
3127  break;
3128  default:
3129  break;
3130  }
3131  }
3132  position_u& operator=(const position_u& other)
3133  {
3134 
3135  m_type = other.m_type;
3136  switch(m_type)
3137  {
3138  case Type::Type0:
3139  new(&m_impl.m_value0) ossia::cartesian_3d_u{other.m_impl.m_value0};
3140  break;
3141  case Type::Type1:
3142  new(&m_impl.m_value1) ossia::cartesian_2d_u{other.m_impl.m_value1};
3143  break;
3144  case Type::Type2:
3145  new(&m_impl.m_value2) ossia::spherical_u{other.m_impl.m_value2};
3146  break;
3147  case Type::Type3:
3148  new(&m_impl.m_value3) ossia::polar_u{other.m_impl.m_value3};
3149  break;
3150  case Type::Type4:
3151  new(&m_impl.m_value4) ossia::aed_u{other.m_impl.m_value4};
3152  break;
3153  case Type::Type5:
3154  new(&m_impl.m_value5) ossia::ad_u{other.m_impl.m_value5};
3155  break;
3156  case Type::Type6:
3157  new(&m_impl.m_value6) ossia::opengl_u{other.m_impl.m_value6};
3158  break;
3159  case Type::Type7:
3160  new(&m_impl.m_value7) ossia::cylindrical_u{other.m_impl.m_value7};
3161  break;
3162  case Type::Type8:
3163  new(&m_impl.m_value8) ossia::azd_u{other.m_impl.m_value8};
3164  break;
3165  default:
3166  break;
3167  }
3168  return *this;
3169  }
3170  position_u& operator=(position_u&& other) noexcept
3171  {
3172 
3173  m_type = other.m_type;
3174  switch(m_type)
3175  {
3176  case Type::Type0:
3177  new(&m_impl.m_value0) ossia::cartesian_3d_u{std::move(other.m_impl.m_value0)};
3178  break;
3179  case Type::Type1:
3180  new(&m_impl.m_value1) ossia::cartesian_2d_u{std::move(other.m_impl.m_value1)};
3181  break;
3182  case Type::Type2:
3183  new(&m_impl.m_value2) ossia::spherical_u{std::move(other.m_impl.m_value2)};
3184  break;
3185  case Type::Type3:
3186  new(&m_impl.m_value3) ossia::polar_u{std::move(other.m_impl.m_value3)};
3187  break;
3188  case Type::Type4:
3189  new(&m_impl.m_value4) ossia::aed_u{std::move(other.m_impl.m_value4)};
3190  break;
3191  case Type::Type5:
3192  new(&m_impl.m_value5) ossia::ad_u{std::move(other.m_impl.m_value5)};
3193  break;
3194  case Type::Type6:
3195  new(&m_impl.m_value6) ossia::opengl_u{std::move(other.m_impl.m_value6)};
3196  break;
3197  case Type::Type7:
3198  new(&m_impl.m_value7) ossia::cylindrical_u{std::move(other.m_impl.m_value7)};
3199  break;
3200  case Type::Type8:
3201  new(&m_impl.m_value8) ossia::azd_u{std::move(other.m_impl.m_value8)};
3202  break;
3203  default:
3204  break;
3205  }
3206  return *this;
3207  }
3208 };
3209 template <>
3210 inline const ossia::cartesian_3d_u* position_u::target() const
3211 {
3212  if(m_type == Type0)
3213  return &m_impl.m_value0;
3214  return nullptr;
3215 }
3216 template <>
3217 inline const ossia::cartesian_2d_u* position_u::target() const
3218 {
3219  if(m_type == Type1)
3220  return &m_impl.m_value1;
3221  return nullptr;
3222 }
3223 template <>
3224 inline const ossia::spherical_u* position_u::target() const
3225 {
3226  if(m_type == Type2)
3227  return &m_impl.m_value2;
3228  return nullptr;
3229 }
3230 template <>
3231 inline const ossia::polar_u* position_u::target() const
3232 {
3233  if(m_type == Type3)
3234  return &m_impl.m_value3;
3235  return nullptr;
3236 }
3237 template <>
3238 inline const ossia::aed_u* position_u::target() const
3239 {
3240  if(m_type == Type4)
3241  return &m_impl.m_value4;
3242  return nullptr;
3243 }
3244 template <>
3245 inline const ossia::ad_u* position_u::target() const
3246 {
3247  if(m_type == Type5)
3248  return &m_impl.m_value5;
3249  return nullptr;
3250 }
3251 template <>
3252 inline const ossia::opengl_u* position_u::target() const
3253 {
3254  if(m_type == Type6)
3255  return &m_impl.m_value6;
3256  return nullptr;
3257 }
3258 template <>
3259 inline const ossia::cylindrical_u* position_u::target() const
3260 {
3261  if(m_type == Type7)
3262  return &m_impl.m_value7;
3263  return nullptr;
3264 }
3265 template <>
3266 inline const ossia::azd_u* position_u::target() const
3267 {
3268  if(m_type == Type8)
3269  return &m_impl.m_value8;
3270  return nullptr;
3271 }
3272 template <>
3273 inline ossia::cartesian_3d_u* position_u::target()
3274 {
3275  if(m_type == Type0)
3276  return &m_impl.m_value0;
3277  return nullptr;
3278 }
3279 template <>
3280 inline ossia::cartesian_2d_u* position_u::target()
3281 {
3282  if(m_type == Type1)
3283  return &m_impl.m_value1;
3284  return nullptr;
3285 }
3286 template <>
3287 inline ossia::spherical_u* position_u::target()
3288 {
3289  if(m_type == Type2)
3290  return &m_impl.m_value2;
3291  return nullptr;
3292 }
3293 template <>
3294 inline ossia::polar_u* position_u::target()
3295 {
3296  if(m_type == Type3)
3297  return &m_impl.m_value3;
3298  return nullptr;
3299 }
3300 template <>
3301 inline ossia::aed_u* position_u::target()
3302 {
3303  if(m_type == Type4)
3304  return &m_impl.m_value4;
3305  return nullptr;
3306 }
3307 template <>
3308 inline ossia::ad_u* position_u::target()
3309 {
3310  if(m_type == Type5)
3311  return &m_impl.m_value5;
3312  return nullptr;
3313 }
3314 template <>
3315 inline ossia::opengl_u* position_u::target()
3316 {
3317  if(m_type == Type6)
3318  return &m_impl.m_value6;
3319  return nullptr;
3320 }
3321 template <>
3322 inline ossia::cylindrical_u* position_u::target()
3323 {
3324  if(m_type == Type7)
3325  return &m_impl.m_value7;
3326  return nullptr;
3327 }
3328 template <>
3329 inline ossia::azd_u* position_u::target()
3330 {
3331  if(m_type == Type8)
3332  return &m_impl.m_value8;
3333  return nullptr;
3334 }
3335 template <>
3336 inline const ossia::cartesian_3d_u& position_u::get() const
3337 {
3338  if(m_type == Type0)
3339  return m_impl.m_value0;
3340  ossia_do_throw(std::runtime_error, "position_u: bad type");
3341 }
3342 template <>
3343 inline const ossia::cartesian_2d_u& position_u::get() const
3344 {
3345  if(m_type == Type1)
3346  return m_impl.m_value1;
3347  ossia_do_throw(std::runtime_error, "position_u: bad type");
3348 }
3349 template <>
3350 inline const ossia::spherical_u& position_u::get() const
3351 {
3352  if(m_type == Type2)
3353  return m_impl.m_value2;
3354  ossia_do_throw(std::runtime_error, "position_u: bad type");
3355 }
3356 template <>
3357 inline const ossia::polar_u& position_u::get() const
3358 {
3359  if(m_type == Type3)
3360  return m_impl.m_value3;
3361  ossia_do_throw(std::runtime_error, "position_u: bad type");
3362 }
3363 template <>
3364 inline const ossia::aed_u& position_u::get() const
3365 {
3366  if(m_type == Type4)
3367  return m_impl.m_value4;
3368  ossia_do_throw(std::runtime_error, "position_u: bad type");
3369 }
3370 template <>
3371 inline const ossia::ad_u& position_u::get() const
3372 {
3373  if(m_type == Type5)
3374  return m_impl.m_value5;
3375  ossia_do_throw(std::runtime_error, "position_u: bad type");
3376 }
3377 template <>
3378 inline const ossia::opengl_u& position_u::get() const
3379 {
3380  if(m_type == Type6)
3381  return m_impl.m_value6;
3382  ossia_do_throw(std::runtime_error, "position_u: bad type");
3383 }
3384 template <>
3385 inline const ossia::cylindrical_u& position_u::get() const
3386 {
3387  if(m_type == Type7)
3388  return m_impl.m_value7;
3389  ossia_do_throw(std::runtime_error, "position_u: bad type");
3390 }
3391 template <>
3392 inline const ossia::azd_u& position_u::get() const
3393 {
3394  if(m_type == Type8)
3395  return m_impl.m_value8;
3396  ossia_do_throw(std::runtime_error, "position_u: bad type");
3397 }
3398 template <>
3399 inline ossia::cartesian_3d_u& position_u::get()
3400 {
3401  if(m_type == Type0)
3402  return m_impl.m_value0;
3403  ossia_do_throw(std::runtime_error, "position_u: bad type");
3404 }
3405 template <>
3406 inline ossia::cartesian_2d_u& position_u::get()
3407 {
3408  if(m_type == Type1)
3409  return m_impl.m_value1;
3410  ossia_do_throw(std::runtime_error, "position_u: bad type");
3411 }
3412 template <>
3413 inline ossia::spherical_u& position_u::get()
3414 {
3415  if(m_type == Type2)
3416  return m_impl.m_value2;
3417  ossia_do_throw(std::runtime_error, "position_u: bad type");
3418 }
3419 template <>
3420 inline ossia::polar_u& position_u::get()
3421 {
3422  if(m_type == Type3)
3423  return m_impl.m_value3;
3424  ossia_do_throw(std::runtime_error, "position_u: bad type");
3425 }
3426 template <>
3427 inline ossia::aed_u& position_u::get()
3428 {
3429  if(m_type == Type4)
3430  return m_impl.m_value4;
3431  ossia_do_throw(std::runtime_error, "position_u: bad type");
3432 }
3433 template <>
3434 inline ossia::ad_u& position_u::get()
3435 {
3436  if(m_type == Type5)
3437  return m_impl.m_value5;
3438  ossia_do_throw(std::runtime_error, "position_u: bad type");
3439 }
3440 template <>
3441 inline ossia::opengl_u& position_u::get()
3442 {
3443  if(m_type == Type6)
3444  return m_impl.m_value6;
3445  ossia_do_throw(std::runtime_error, "position_u: bad type");
3446 }
3447 template <>
3448 inline ossia::cylindrical_u& position_u::get()
3449 {
3450  if(m_type == Type7)
3451  return m_impl.m_value7;
3452  ossia_do_throw(std::runtime_error, "position_u: bad type");
3453 }
3454 template <>
3455 inline ossia::azd_u& position_u::get()
3456 {
3457  if(m_type == Type8)
3458  return m_impl.m_value8;
3459  ossia_do_throw(std::runtime_error, "position_u: bad type");
3460 }
3461 template <typename Visitor>
3462 auto apply_nonnull(Visitor&& functor, const position_u& var)
3463 {
3464  switch(var.m_type)
3465  {
3466  case position_u::Type::Type0:
3467  return functor(var.m_impl.m_value0);
3468  case position_u::Type::Type1:
3469  return functor(var.m_impl.m_value1);
3470  case position_u::Type::Type2:
3471  return functor(var.m_impl.m_value2);
3472  case position_u::Type::Type3:
3473  return functor(var.m_impl.m_value3);
3474  case position_u::Type::Type4:
3475  return functor(var.m_impl.m_value4);
3476  case position_u::Type::Type5:
3477  return functor(var.m_impl.m_value5);
3478  case position_u::Type::Type6:
3479  return functor(var.m_impl.m_value6);
3480  case position_u::Type::Type7:
3481  return functor(var.m_impl.m_value7);
3482  case position_u::Type::Type8:
3483  return functor(var.m_impl.m_value8);
3484  default:
3485  ossia_do_throw(std::runtime_error, "position_u: bad type");
3486  }
3487 }
3488 template <typename Visitor>
3489 auto apply_nonnull(Visitor&& functor, position_u& var)
3490 {
3491  switch(var.m_type)
3492  {
3493  case position_u::Type::Type0:
3494  return functor(var.m_impl.m_value0);
3495  case position_u::Type::Type1:
3496  return functor(var.m_impl.m_value1);
3497  case position_u::Type::Type2:
3498  return functor(var.m_impl.m_value2);
3499  case position_u::Type::Type3:
3500  return functor(var.m_impl.m_value3);
3501  case position_u::Type::Type4:
3502  return functor(var.m_impl.m_value4);
3503  case position_u::Type::Type5:
3504  return functor(var.m_impl.m_value5);
3505  case position_u::Type::Type6:
3506  return functor(var.m_impl.m_value6);
3507  case position_u::Type::Type7:
3508  return functor(var.m_impl.m_value7);
3509  case position_u::Type::Type8:
3510  return functor(var.m_impl.m_value8);
3511  default:
3512  ossia_do_throw(std::runtime_error, "position_u: bad type");
3513  }
3514 }
3515 template <typename Visitor>
3516 auto apply_nonnull(Visitor&& functor, position_u&& var)
3517 {
3518  switch(var.m_type)
3519  {
3520  case position_u::Type::Type0:
3521  return functor(std::move(var.m_impl.m_value0));
3522  case position_u::Type::Type1:
3523  return functor(std::move(var.m_impl.m_value1));
3524  case position_u::Type::Type2:
3525  return functor(std::move(var.m_impl.m_value2));
3526  case position_u::Type::Type3:
3527  return functor(std::move(var.m_impl.m_value3));
3528  case position_u::Type::Type4:
3529  return functor(std::move(var.m_impl.m_value4));
3530  case position_u::Type::Type5:
3531  return functor(std::move(var.m_impl.m_value5));
3532  case position_u::Type::Type6:
3533  return functor(std::move(var.m_impl.m_value6));
3534  case position_u::Type::Type7:
3535  return functor(std::move(var.m_impl.m_value7));
3536  case position_u::Type::Type8:
3537  return functor(std::move(var.m_impl.m_value8));
3538  default:
3539  ossia_do_throw(std::runtime_error, "position_u: bad type");
3540  }
3541 }
3542 template <typename Visitor>
3543 auto apply(Visitor&& functor, const position_u& var)
3544 {
3545  switch(var.m_type)
3546  {
3547  case position_u::Type::Type0:
3548  return functor(var.m_impl.m_value0);
3549  case position_u::Type::Type1:
3550  return functor(var.m_impl.m_value1);
3551  case position_u::Type::Type2:
3552  return functor(var.m_impl.m_value2);
3553  case position_u::Type::Type3:
3554  return functor(var.m_impl.m_value3);
3555  case position_u::Type::Type4:
3556  return functor(var.m_impl.m_value4);
3557  case position_u::Type::Type5:
3558  return functor(var.m_impl.m_value5);
3559  case position_u::Type::Type6:
3560  return functor(var.m_impl.m_value6);
3561  case position_u::Type::Type7:
3562  return functor(var.m_impl.m_value7);
3563  case position_u::Type::Type8:
3564  return functor(var.m_impl.m_value8);
3565  default:
3566  return functor();
3567  }
3568 }
3569 template <typename Visitor>
3570 auto apply(Visitor&& functor, position_u& var)
3571 {
3572  switch(var.m_type)
3573  {
3574  case position_u::Type::Type0:
3575  return functor(var.m_impl.m_value0);
3576  case position_u::Type::Type1:
3577  return functor(var.m_impl.m_value1);
3578  case position_u::Type::Type2:
3579  return functor(var.m_impl.m_value2);
3580  case position_u::Type::Type3:
3581  return functor(var.m_impl.m_value3);
3582  case position_u::Type::Type4:
3583  return functor(var.m_impl.m_value4);
3584  case position_u::Type::Type5:
3585  return functor(var.m_impl.m_value5);
3586  case position_u::Type::Type6:
3587  return functor(var.m_impl.m_value6);
3588  case position_u::Type::Type7:
3589  return functor(var.m_impl.m_value7);
3590  case position_u::Type::Type8:
3591  return functor(var.m_impl.m_value8);
3592  default:
3593  return functor();
3594  }
3595 }
3596 template <typename Visitor>
3597 auto apply(Visitor&& functor, position_u&& var)
3598 {
3599  switch(var.m_type)
3600  {
3601  case position_u::Type::Type0:
3602  return functor(std::move(var.m_impl.m_value0));
3603  case position_u::Type::Type1:
3604  return functor(std::move(var.m_impl.m_value1));
3605  case position_u::Type::Type2:
3606  return functor(std::move(var.m_impl.m_value2));
3607  case position_u::Type::Type3:
3608  return functor(std::move(var.m_impl.m_value3));
3609  case position_u::Type::Type4:
3610  return functor(std::move(var.m_impl.m_value4));
3611  case position_u::Type::Type5:
3612  return functor(std::move(var.m_impl.m_value5));
3613  case position_u::Type::Type6:
3614  return functor(std::move(var.m_impl.m_value6));
3615  case position_u::Type::Type7:
3616  return functor(std::move(var.m_impl.m_value7));
3617  case position_u::Type::Type8:
3618  return functor(std::move(var.m_impl.m_value8));
3619  default:
3620  return functor();
3621  }
3622 }
3623 inline bool operator==(const position_u& lhs, const position_u& rhs)
3624 {
3625  return (lhs.m_type == rhs.m_type);
3626 }
3627 inline bool operator!=(const position_u& lhs, const position_u& rhs)
3628 {
3629  return (lhs.m_type != rhs.m_type);
3630 }
3631 inline bool operator==(const position_u& lhs, const ossia::cartesian_3d_u& rhs)
3632 {
3633  return (lhs.m_type == position_u::Type::Type0);
3634 }
3635 inline bool operator==(const ossia::cartesian_3d_u& lhs, const position_u& rhs)
3636 {
3637  return (rhs.m_type == position_u::Type::Type0);
3638 }
3639 inline bool operator!=(const position_u& lhs, const ossia::cartesian_3d_u& rhs)
3640 {
3641  return (lhs.m_type != position_u::Type::Type0);
3642 }
3643 inline bool operator!=(const ossia::cartesian_3d_u& lhs, const position_u& rhs)
3644 {
3645  return (rhs.m_type != position_u::Type::Type0);
3646 }
3647 inline bool operator==(const position_u& lhs, const ossia::cartesian_2d_u& rhs)
3648 {
3649  return (lhs.m_type == position_u::Type::Type1);
3650 }
3651 inline bool operator==(const ossia::cartesian_2d_u& lhs, const position_u& rhs)
3652 {
3653  return (rhs.m_type == position_u::Type::Type1);
3654 }
3655 inline bool operator!=(const position_u& lhs, const ossia::cartesian_2d_u& rhs)
3656 {
3657  return (lhs.m_type != position_u::Type::Type1);
3658 }
3659 inline bool operator!=(const ossia::cartesian_2d_u& lhs, const position_u& rhs)
3660 {
3661  return (rhs.m_type != position_u::Type::Type1);
3662 }
3663 inline bool operator==(const position_u& lhs, const ossia::spherical_u& rhs)
3664 {
3665  return (lhs.m_type == position_u::Type::Type2);
3666 }
3667 inline bool operator==(const ossia::spherical_u& lhs, const position_u& rhs)
3668 {
3669  return (rhs.m_type == position_u::Type::Type2);
3670 }
3671 inline bool operator!=(const position_u& lhs, const ossia::spherical_u& rhs)
3672 {
3673  return (lhs.m_type != position_u::Type::Type2);
3674 }
3675 inline bool operator!=(const ossia::spherical_u& lhs, const position_u& rhs)
3676 {
3677  return (rhs.m_type != position_u::Type::Type2);
3678 }
3679 inline bool operator==(const position_u& lhs, const ossia::polar_u& rhs)
3680 {
3681  return (lhs.m_type == position_u::Type::Type3);
3682 }
3683 inline bool operator==(const ossia::polar_u& lhs, const position_u& rhs)
3684 {
3685  return (rhs.m_type == position_u::Type::Type3);
3686 }
3687 inline bool operator!=(const position_u& lhs, const ossia::polar_u& rhs)
3688 {
3689  return (lhs.m_type != position_u::Type::Type3);
3690 }
3691 inline bool operator!=(const ossia::polar_u& lhs, const position_u& rhs)
3692 {
3693  return (rhs.m_type != position_u::Type::Type3);
3694 }
3695 inline bool operator==(const position_u& lhs, const ossia::aed_u& rhs)
3696 {
3697  return (lhs.m_type == position_u::Type::Type4);
3698 }
3699 inline bool operator==(const ossia::aed_u& lhs, const position_u& rhs)
3700 {
3701  return (rhs.m_type == position_u::Type::Type4);
3702 }
3703 inline bool operator!=(const position_u& lhs, const ossia::aed_u& rhs)
3704 {
3705  return (lhs.m_type != position_u::Type::Type4);
3706 }
3707 inline bool operator!=(const ossia::aed_u& lhs, const position_u& rhs)
3708 {
3709  return (rhs.m_type != position_u::Type::Type4);
3710 }
3711 inline bool operator==(const position_u& lhs, const ossia::ad_u& rhs)
3712 {
3713  return (lhs.m_type == position_u::Type::Type5);
3714 }
3715 inline bool operator==(const ossia::ad_u& lhs, const position_u& rhs)
3716 {
3717  return (rhs.m_type == position_u::Type::Type5);
3718 }
3719 inline bool operator!=(const position_u& lhs, const ossia::ad_u& rhs)
3720 {
3721  return (lhs.m_type != position_u::Type::Type5);
3722 }
3723 inline bool operator!=(const ossia::ad_u& lhs, const position_u& rhs)
3724 {
3725  return (rhs.m_type != position_u::Type::Type5);
3726 }
3727 inline bool operator==(const position_u& lhs, const ossia::opengl_u& rhs)
3728 {
3729  return (lhs.m_type == position_u::Type::Type6);
3730 }
3731 inline bool operator==(const ossia::opengl_u& lhs, const position_u& rhs)
3732 {
3733  return (rhs.m_type == position_u::Type::Type6);
3734 }
3735 inline bool operator!=(const position_u& lhs, const ossia::opengl_u& rhs)
3736 {
3737  return (lhs.m_type != position_u::Type::Type6);
3738 }
3739 inline bool operator!=(const ossia::opengl_u& lhs, const position_u& rhs)
3740 {
3741  return (rhs.m_type != position_u::Type::Type6);
3742 }
3743 inline bool operator==(const position_u& lhs, const ossia::cylindrical_u& rhs)
3744 {
3745  return (lhs.m_type == position_u::Type::Type7);
3746 }
3747 inline bool operator==(const ossia::cylindrical_u& lhs, const position_u& rhs)
3748 {
3749  return (rhs.m_type == position_u::Type::Type7);
3750 }
3751 inline bool operator!=(const position_u& lhs, const ossia::cylindrical_u& rhs)
3752 {
3753  return (lhs.m_type != position_u::Type::Type7);
3754 }
3755 inline bool operator!=(const ossia::cylindrical_u& lhs, const position_u& rhs)
3756 {
3757  return (rhs.m_type != position_u::Type::Type7);
3758 }
3759 inline bool operator==(const position_u& lhs, const ossia::azd_u& rhs)
3760 {
3761  return (lhs.m_type == position_u::Type::Type8);
3762 }
3763 inline bool operator==(const ossia::azd_u& lhs, const position_u& rhs)
3764 {
3765  return (rhs.m_type == position_u::Type::Type8);
3766 }
3767 inline bool operator!=(const position_u& lhs, const ossia::azd_u& rhs)
3768 {
3769  return (lhs.m_type != position_u::Type::Type8);
3770 }
3771 inline bool operator!=(const ossia::azd_u& lhs, const position_u& rhs)
3772 {
3773  return (rhs.m_type != position_u::Type::Type8);
3774 }
3775 struct speed_u
3776 {
3777 public:
3778  struct dummy_t
3779  {
3780  };
3781  union Impl
3782  {
3783  ossia::meter_per_second_u m_value0;
3784 
3785  ossia::miles_per_hour_u m_value1;
3786 
3787  ossia::kilometer_per_hour_u m_value2;
3788 
3789  ossia::knot_u m_value3;
3790 
3791  ossia::foot_per_second_u m_value4;
3792 
3793  ossia::foot_per_hour_u m_value5;
3794 
3795  dummy_t m_dummy;
3796  Impl()
3797  : m_dummy{}
3798  {
3799  }
3800  ~Impl() = default;
3801  };
3802 
3803  enum Type : int8_t
3804  {
3805  Type0,
3806  Type1,
3807  Type2,
3808  Type3,
3809  Type4,
3810  Type5,
3812  };
3813 
3814  Impl m_impl;
3815  Type m_type;
3816 
3817 public:
3818  static const constexpr auto npos = Npos;
3819  int which() const { return m_type; }
3820 
3821  operator bool() const { return m_type != npos; }
3822  template <typename T>
3823  const T* target() const;
3824  template <typename T>
3825  T* target();
3826  template <typename T>
3827  const T& get() const;
3828  template <typename T>
3829  T& get();
3830 
3831  template <typename T>
3832  static Type matching_type();
3833  speed_u()
3834  : m_type{Npos}
3835  {
3836  }
3837  ~speed_u() = default;
3838  speed_u(ossia::meter_per_second_u v)
3839  : m_type{Type0}
3840  {
3841  new(&m_impl.m_value0) ossia::meter_per_second_u{v};
3842  }
3843  speed_u(ossia::miles_per_hour_u v)
3844  : m_type{Type1}
3845  {
3846  new(&m_impl.m_value1) ossia::miles_per_hour_u{v};
3847  }
3848  speed_u(ossia::kilometer_per_hour_u v)
3849  : m_type{Type2}
3850  {
3851  new(&m_impl.m_value2) ossia::kilometer_per_hour_u{v};
3852  }
3853  speed_u(ossia::knot_u v)
3854  : m_type{Type3}
3855  {
3856  new(&m_impl.m_value3) ossia::knot_u{v};
3857  }
3858  speed_u(ossia::foot_per_second_u v)
3859  : m_type{Type4}
3860  {
3861  new(&m_impl.m_value4) ossia::foot_per_second_u{v};
3862  }
3863  speed_u(ossia::foot_per_hour_u v)
3864  : m_type{Type5}
3865  {
3866  new(&m_impl.m_value5) ossia::foot_per_hour_u{v};
3867  }
3868  speed_u(const speed_u& other)
3869  : m_type{other.m_type}
3870  {
3871  switch(m_type)
3872  {
3873  case Type::Type0:
3874  new(&m_impl.m_value0) ossia::meter_per_second_u{other.m_impl.m_value0};
3875  break;
3876  case Type::Type1:
3877  new(&m_impl.m_value1) ossia::miles_per_hour_u{other.m_impl.m_value1};
3878  break;
3879  case Type::Type2:
3880  new(&m_impl.m_value2) ossia::kilometer_per_hour_u{other.m_impl.m_value2};
3881  break;
3882  case Type::Type3:
3883  new(&m_impl.m_value3) ossia::knot_u{other.m_impl.m_value3};
3884  break;
3885  case Type::Type4:
3886  new(&m_impl.m_value4) ossia::foot_per_second_u{other.m_impl.m_value4};
3887  break;
3888  case Type::Type5:
3889  new(&m_impl.m_value5) ossia::foot_per_hour_u{other.m_impl.m_value5};
3890  break;
3891  default:
3892  break;
3893  }
3894  }
3895  speed_u(speed_u&& other) noexcept
3896  : m_type{other.m_type}
3897  {
3898  switch(m_type)
3899  {
3900  case Type::Type0:
3901  new(&m_impl.m_value0)
3902  ossia::meter_per_second_u{std::move(other.m_impl.m_value0)};
3903  break;
3904  case Type::Type1:
3905  new(&m_impl.m_value1) ossia::miles_per_hour_u{std::move(other.m_impl.m_value1)};
3906  break;
3907  case Type::Type2:
3908  new(&m_impl.m_value2)
3909  ossia::kilometer_per_hour_u{std::move(other.m_impl.m_value2)};
3910  break;
3911  case Type::Type3:
3912  new(&m_impl.m_value3) ossia::knot_u{std::move(other.m_impl.m_value3)};
3913  break;
3914  case Type::Type4:
3915  new(&m_impl.m_value4) ossia::foot_per_second_u{std::move(other.m_impl.m_value4)};
3916  break;
3917  case Type::Type5:
3918  new(&m_impl.m_value5) ossia::foot_per_hour_u{std::move(other.m_impl.m_value5)};
3919  break;
3920  default:
3921  break;
3922  }
3923  }
3924  speed_u& operator=(const speed_u& other)
3925  {
3926 
3927  m_type = other.m_type;
3928  switch(m_type)
3929  {
3930  case Type::Type0:
3931  new(&m_impl.m_value0) ossia::meter_per_second_u{other.m_impl.m_value0};
3932  break;
3933  case Type::Type1:
3934  new(&m_impl.m_value1) ossia::miles_per_hour_u{other.m_impl.m_value1};
3935  break;
3936  case Type::Type2:
3937  new(&m_impl.m_value2) ossia::kilometer_per_hour_u{other.m_impl.m_value2};
3938  break;
3939  case Type::Type3:
3940  new(&m_impl.m_value3) ossia::knot_u{other.m_impl.m_value3};
3941  break;
3942  case Type::Type4:
3943  new(&m_impl.m_value4) ossia::foot_per_second_u{other.m_impl.m_value4};
3944  break;
3945  case Type::Type5:
3946  new(&m_impl.m_value5) ossia::foot_per_hour_u{other.m_impl.m_value5};
3947  break;
3948  default:
3949  break;
3950  }
3951  return *this;
3952  }
3953  speed_u& operator=(speed_u&& other) noexcept
3954  {
3955 
3956  m_type = other.m_type;
3957  switch(m_type)
3958  {
3959  case Type::Type0:
3960  new(&m_impl.m_value0)
3961  ossia::meter_per_second_u{std::move(other.m_impl.m_value0)};
3962  break;
3963  case Type::Type1:
3964  new(&m_impl.m_value1) ossia::miles_per_hour_u{std::move(other.m_impl.m_value1)};
3965  break;
3966  case Type::Type2:
3967  new(&m_impl.m_value2)
3968  ossia::kilometer_per_hour_u{std::move(other.m_impl.m_value2)};
3969  break;
3970  case Type::Type3:
3971  new(&m_impl.m_value3) ossia::knot_u{std::move(other.m_impl.m_value3)};
3972  break;
3973  case Type::Type4:
3974  new(&m_impl.m_value4) ossia::foot_per_second_u{std::move(other.m_impl.m_value4)};
3975  break;
3976  case Type::Type5:
3977  new(&m_impl.m_value5) ossia::foot_per_hour_u{std::move(other.m_impl.m_value5)};
3978  break;
3979  default:
3980  break;
3981  }
3982  return *this;
3983  }
3984 };
3985 template <>
3986 inline const ossia::meter_per_second_u* speed_u::target() const
3987 {
3988  if(m_type == Type0)
3989  return &m_impl.m_value0;
3990  return nullptr;
3991 }
3992 template <>
3993 inline const ossia::miles_per_hour_u* speed_u::target() const
3994 {
3995  if(m_type == Type1)
3996  return &m_impl.m_value1;
3997  return nullptr;
3998 }
3999 template <>
4000 inline const ossia::kilometer_per_hour_u* speed_u::target() const
4001 {
4002  if(m_type == Type2)
4003  return &m_impl.m_value2;
4004  return nullptr;
4005 }
4006 template <>
4007 inline const ossia::knot_u* speed_u::target() const
4008 {
4009  if(m_type == Type3)
4010  return &m_impl.m_value3;
4011  return nullptr;
4012 }
4013 template <>
4014 inline const ossia::foot_per_second_u* speed_u::target() const
4015 {
4016  if(m_type == Type4)
4017  return &m_impl.m_value4;
4018  return nullptr;
4019 }
4020 template <>
4021 inline const ossia::foot_per_hour_u* speed_u::target() const
4022 {
4023  if(m_type == Type5)
4024  return &m_impl.m_value5;
4025  return nullptr;
4026 }
4027 template <>
4028 inline ossia::meter_per_second_u* speed_u::target()
4029 {
4030  if(m_type == Type0)
4031  return &m_impl.m_value0;
4032  return nullptr;
4033 }
4034 template <>
4035 inline ossia::miles_per_hour_u* speed_u::target()
4036 {
4037  if(m_type == Type1)
4038  return &m_impl.m_value1;
4039  return nullptr;
4040 }
4041 template <>
4042 inline ossia::kilometer_per_hour_u* speed_u::target()
4043 {
4044  if(m_type == Type2)
4045  return &m_impl.m_value2;
4046  return nullptr;
4047 }
4048 template <>
4049 inline ossia::knot_u* speed_u::target()
4050 {
4051  if(m_type == Type3)
4052  return &m_impl.m_value3;
4053  return nullptr;
4054 }
4055 template <>
4056 inline ossia::foot_per_second_u* speed_u::target()
4057 {
4058  if(m_type == Type4)
4059  return &m_impl.m_value4;
4060  return nullptr;
4061 }
4062 template <>
4063 inline ossia::foot_per_hour_u* speed_u::target()
4064 {
4065  if(m_type == Type5)
4066  return &m_impl.m_value5;
4067  return nullptr;
4068 }
4069 template <>
4070 inline const ossia::meter_per_second_u& speed_u::get() const
4071 {
4072  if(m_type == Type0)
4073  return m_impl.m_value0;
4074  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4075 }
4076 template <>
4077 inline const ossia::miles_per_hour_u& speed_u::get() const
4078 {
4079  if(m_type == Type1)
4080  return m_impl.m_value1;
4081  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4082 }
4083 template <>
4084 inline const ossia::kilometer_per_hour_u& speed_u::get() const
4085 {
4086  if(m_type == Type2)
4087  return m_impl.m_value2;
4088  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4089 }
4090 template <>
4091 inline const ossia::knot_u& speed_u::get() const
4092 {
4093  if(m_type == Type3)
4094  return m_impl.m_value3;
4095  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4096 }
4097 template <>
4098 inline const ossia::foot_per_second_u& speed_u::get() const
4099 {
4100  if(m_type == Type4)
4101  return m_impl.m_value4;
4102  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4103 }
4104 template <>
4105 inline const ossia::foot_per_hour_u& speed_u::get() const
4106 {
4107  if(m_type == Type5)
4108  return m_impl.m_value5;
4109  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4110 }
4111 template <>
4112 inline ossia::meter_per_second_u& speed_u::get()
4113 {
4114  if(m_type == Type0)
4115  return m_impl.m_value0;
4116  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4117 }
4118 template <>
4119 inline ossia::miles_per_hour_u& speed_u::get()
4120 {
4121  if(m_type == Type1)
4122  return m_impl.m_value1;
4123  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4124 }
4125 template <>
4126 inline ossia::kilometer_per_hour_u& speed_u::get()
4127 {
4128  if(m_type == Type2)
4129  return m_impl.m_value2;
4130  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4131 }
4132 template <>
4133 inline ossia::knot_u& speed_u::get()
4134 {
4135  if(m_type == Type3)
4136  return m_impl.m_value3;
4137  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4138 }
4139 template <>
4140 inline ossia::foot_per_second_u& speed_u::get()
4141 {
4142  if(m_type == Type4)
4143  return m_impl.m_value4;
4144  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4145 }
4146 template <>
4147 inline ossia::foot_per_hour_u& speed_u::get()
4148 {
4149  if(m_type == Type5)
4150  return m_impl.m_value5;
4151  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4152 }
4153 template <typename Visitor>
4154 auto apply_nonnull(Visitor&& functor, const speed_u& var)
4155 {
4156  switch(var.m_type)
4157  {
4158  case speed_u::Type::Type0:
4159  return functor(var.m_impl.m_value0);
4160  case speed_u::Type::Type1:
4161  return functor(var.m_impl.m_value1);
4162  case speed_u::Type::Type2:
4163  return functor(var.m_impl.m_value2);
4164  case speed_u::Type::Type3:
4165  return functor(var.m_impl.m_value3);
4166  case speed_u::Type::Type4:
4167  return functor(var.m_impl.m_value4);
4168  case speed_u::Type::Type5:
4169  return functor(var.m_impl.m_value5);
4170  default:
4171  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4172  }
4173 }
4174 template <typename Visitor>
4175 auto apply_nonnull(Visitor&& functor, speed_u& var)
4176 {
4177  switch(var.m_type)
4178  {
4179  case speed_u::Type::Type0:
4180  return functor(var.m_impl.m_value0);
4181  case speed_u::Type::Type1:
4182  return functor(var.m_impl.m_value1);
4183  case speed_u::Type::Type2:
4184  return functor(var.m_impl.m_value2);
4185  case speed_u::Type::Type3:
4186  return functor(var.m_impl.m_value3);
4187  case speed_u::Type::Type4:
4188  return functor(var.m_impl.m_value4);
4189  case speed_u::Type::Type5:
4190  return functor(var.m_impl.m_value5);
4191  default:
4192  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4193  }
4194 }
4195 template <typename Visitor>
4196 auto apply_nonnull(Visitor&& functor, speed_u&& var)
4197 {
4198  switch(var.m_type)
4199  {
4200  case speed_u::Type::Type0:
4201  return functor(std::move(var.m_impl.m_value0));
4202  case speed_u::Type::Type1:
4203  return functor(std::move(var.m_impl.m_value1));
4204  case speed_u::Type::Type2:
4205  return functor(std::move(var.m_impl.m_value2));
4206  case speed_u::Type::Type3:
4207  return functor(std::move(var.m_impl.m_value3));
4208  case speed_u::Type::Type4:
4209  return functor(std::move(var.m_impl.m_value4));
4210  case speed_u::Type::Type5:
4211  return functor(std::move(var.m_impl.m_value5));
4212  default:
4213  ossia_do_throw(std::runtime_error, "speed_u: bad type");
4214  }
4215 }
4216 template <typename Visitor>
4217 auto apply(Visitor&& functor, const speed_u& var)
4218 {
4219  switch(var.m_type)
4220  {
4221  case speed_u::Type::Type0:
4222  return functor(var.m_impl.m_value0);
4223  case speed_u::Type::Type1:
4224  return functor(var.m_impl.m_value1);
4225  case speed_u::Type::Type2:
4226  return functor(var.m_impl.m_value2);
4227  case speed_u::Type::Type3:
4228  return functor(var.m_impl.m_value3);
4229  case speed_u::Type::Type4:
4230  return functor(var.m_impl.m_value4);
4231  case speed_u::Type::Type5:
4232  return functor(var.m_impl.m_value5);
4233  default:
4234  return functor();
4235  }
4236 }
4237 template <typename Visitor>
4238 auto apply(Visitor&& functor, speed_u& var)
4239 {
4240  switch(var.m_type)
4241  {
4242  case speed_u::Type::Type0:
4243  return functor(var.m_impl.m_value0);
4244  case speed_u::Type::Type1:
4245  return functor(var.m_impl.m_value1);
4246  case speed_u::Type::Type2:
4247  return functor(var.m_impl.m_value2);
4248  case speed_u::Type::Type3:
4249  return functor(var.m_impl.m_value3);
4250  case speed_u::Type::Type4:
4251  return functor(var.m_impl.m_value4);
4252  case speed_u::Type::Type5:
4253  return functor(var.m_impl.m_value5);
4254  default:
4255  return functor();
4256  }
4257 }
4258 template <typename Visitor>
4259 auto apply(Visitor&& functor, speed_u&& var)
4260 {
4261  switch(var.m_type)
4262  {
4263  case speed_u::Type::Type0:
4264  return functor(std::move(var.m_impl.m_value0));
4265  case speed_u::Type::Type1:
4266  return functor(std::move(var.m_impl.m_value1));
4267  case speed_u::Type::Type2:
4268  return functor(std::move(var.m_impl.m_value2));
4269  case speed_u::Type::Type3:
4270  return functor(std::move(var.m_impl.m_value3));
4271  case speed_u::Type::Type4:
4272  return functor(std::move(var.m_impl.m_value4));
4273  case speed_u::Type::Type5:
4274  return functor(std::move(var.m_impl.m_value5));
4275  default:
4276  return functor();
4277  }
4278 }
4279 inline bool operator==(const speed_u& lhs, const speed_u& rhs)
4280 {
4281  return (lhs.m_type == rhs.m_type);
4282 }
4283 inline bool operator!=(const speed_u& lhs, const speed_u& rhs)
4284 {
4285  return (lhs.m_type != rhs.m_type);
4286 }
4287 inline bool operator==(const speed_u& lhs, const ossia::meter_per_second_u& rhs)
4288 {
4289  return (lhs.m_type == speed_u::Type::Type0);
4290 }
4291 inline bool operator==(const ossia::meter_per_second_u& lhs, const speed_u& rhs)
4292 {
4293  return (rhs.m_type == speed_u::Type::Type0);
4294 }
4295 inline bool operator!=(const speed_u& lhs, const ossia::meter_per_second_u& rhs)
4296 {
4297  return (lhs.m_type != speed_u::Type::Type0);
4298 }
4299 inline bool operator!=(const ossia::meter_per_second_u& lhs, const speed_u& rhs)
4300 {
4301  return (rhs.m_type != speed_u::Type::Type0);
4302 }
4303 inline bool operator==(const speed_u& lhs, const ossia::miles_per_hour_u& rhs)
4304 {
4305  return (lhs.m_type == speed_u::Type::Type1);
4306 }
4307 inline bool operator==(const ossia::miles_per_hour_u& lhs, const speed_u& rhs)
4308 {
4309  return (rhs.m_type == speed_u::Type::Type1);
4310 }
4311 inline bool operator!=(const speed_u& lhs, const ossia::miles_per_hour_u& rhs)
4312 {
4313  return (lhs.m_type != speed_u::Type::Type1);
4314 }
4315 inline bool operator!=(const ossia::miles_per_hour_u& lhs, const speed_u& rhs)
4316 {
4317  return (rhs.m_type != speed_u::Type::Type1);
4318 }
4319 inline bool operator==(const speed_u& lhs, const ossia::kilometer_per_hour_u& rhs)
4320 {
4321  return (lhs.m_type == speed_u::Type::Type2);
4322 }
4323 inline bool operator==(const ossia::kilometer_per_hour_u& lhs, const speed_u& rhs)
4324 {
4325  return (rhs.m_type == speed_u::Type::Type2);
4326 }
4327 inline bool operator!=(const speed_u& lhs, const ossia::kilometer_per_hour_u& rhs)
4328 {
4329  return (lhs.m_type != speed_u::Type::Type2);
4330 }
4331 inline bool operator!=(const ossia::kilometer_per_hour_u& lhs, const speed_u& rhs)
4332 {
4333  return (rhs.m_type != speed_u::Type::Type2);
4334 }
4335 inline bool operator==(const speed_u& lhs, const ossia::knot_u& rhs)
4336 {
4337  return (lhs.m_type == speed_u::Type::Type3);
4338 }
4339 inline bool operator==(const ossia::knot_u& lhs, const speed_u& rhs)
4340 {
4341  return (rhs.m_type == speed_u::Type::Type3);
4342 }
4343 inline bool operator!=(const speed_u& lhs, const ossia::knot_u& rhs)
4344 {
4345  return (lhs.m_type != speed_u::Type::Type3);
4346 }
4347 inline bool operator!=(const ossia::knot_u& lhs, const speed_u& rhs)
4348 {
4349  return (rhs.m_type != speed_u::Type::Type3);
4350 }
4351 inline bool operator==(const speed_u& lhs, const ossia::foot_per_second_u& rhs)
4352 {
4353  return (lhs.m_type == speed_u::Type::Type4);
4354 }
4355 inline bool operator==(const ossia::foot_per_second_u& lhs, const speed_u& rhs)
4356 {
4357  return (rhs.m_type == speed_u::Type::Type4);
4358 }
4359 inline bool operator!=(const speed_u& lhs, const ossia::foot_per_second_u& rhs)
4360 {
4361  return (lhs.m_type != speed_u::Type::Type4);
4362 }
4363 inline bool operator!=(const ossia::foot_per_second_u& lhs, const speed_u& rhs)
4364 {
4365  return (rhs.m_type != speed_u::Type::Type4);
4366 }
4367 inline bool operator==(const speed_u& lhs, const ossia::foot_per_hour_u& rhs)
4368 {
4369  return (lhs.m_type == speed_u::Type::Type5);
4370 }
4371 inline bool operator==(const ossia::foot_per_hour_u& lhs, const speed_u& rhs)
4372 {
4373  return (rhs.m_type == speed_u::Type::Type5);
4374 }
4375 inline bool operator!=(const speed_u& lhs, const ossia::foot_per_hour_u& rhs)
4376 {
4377  return (lhs.m_type != speed_u::Type::Type5);
4378 }
4379 inline bool operator!=(const ossia::foot_per_hour_u& lhs, const speed_u& rhs)
4380 {
4381  return (rhs.m_type != speed_u::Type::Type5);
4382 }
4383 struct timing_u
4384 {
4385 public:
4386  struct dummy_t
4387  {
4388  };
4389  union Impl
4390  {
4391  ossia::second_u m_value0;
4392 
4393  ossia::bark_u m_value1;
4394 
4395  ossia::bpm_u m_value2;
4396 
4397  ossia::cent_u m_value3;
4398 
4399  ossia::frequency_u m_value4;
4400 
4401  ossia::mel_u m_value5;
4402 
4403  ossia::midi_pitch_u m_value6;
4404 
4405  ossia::millisecond_u m_value7;
4406 
4407  ossia::playback_speed_u m_value8;
4408 
4409  dummy_t m_dummy;
4410  Impl()
4411  : m_dummy{}
4412  {
4413  }
4414  ~Impl() = default;
4415  };
4416 
4417  enum Type : int8_t
4418  {
4419  Type0,
4420  Type1,
4421  Type2,
4422  Type3,
4423  Type4,
4424  Type5,
4425  Type6,
4426  Type7,
4427  Type8,
4429  };
4430 
4431  Impl m_impl;
4432  Type m_type;
4433 
4434 public:
4435  static const constexpr auto npos = Npos;
4436  int which() const { return m_type; }
4437 
4438  operator bool() const { return m_type != npos; }
4439  template <typename T>
4440  const T* target() const;
4441  template <typename T>
4442  T* target();
4443  template <typename T>
4444  const T& get() const;
4445  template <typename T>
4446  T& get();
4447 
4448  template <typename T>
4449  static Type matching_type();
4450  timing_u()
4451  : m_type{Npos}
4452  {
4453  }
4454  ~timing_u() = default;
4455  timing_u(ossia::second_u v)
4456  : m_type{Type0}
4457  {
4458  new(&m_impl.m_value0) ossia::second_u{v};
4459  }
4460  timing_u(ossia::bark_u v)
4461  : m_type{Type1}
4462  {
4463  new(&m_impl.m_value1) ossia::bark_u{v};
4464  }
4465  timing_u(ossia::bpm_u v)
4466  : m_type{Type2}
4467  {
4468  new(&m_impl.m_value2) ossia::bpm_u{v};
4469  }
4470  timing_u(ossia::cent_u v)
4471  : m_type{Type3}
4472  {
4473  new(&m_impl.m_value3) ossia::cent_u{v};
4474  }
4475  timing_u(ossia::frequency_u v)
4476  : m_type{Type4}
4477  {
4478  new(&m_impl.m_value4) ossia::frequency_u{v};
4479  }
4480  timing_u(ossia::mel_u v)
4481  : m_type{Type5}
4482  {
4483  new(&m_impl.m_value5) ossia::mel_u{v};
4484  }
4485  timing_u(ossia::midi_pitch_u v)
4486  : m_type{Type6}
4487  {
4488  new(&m_impl.m_value6) ossia::midi_pitch_u{v};
4489  }
4490  timing_u(ossia::millisecond_u v)
4491  : m_type{Type7}
4492  {
4493  new(&m_impl.m_value7) ossia::millisecond_u{v};
4494  }
4495  timing_u(ossia::playback_speed_u v)
4496  : m_type{Type8}
4497  {
4498  new(&m_impl.m_value8) ossia::playback_speed_u{v};
4499  }
4500  timing_u(const timing_u& other)
4501  : m_type{other.m_type}
4502  {
4503  switch(m_type)
4504  {
4505  case Type::Type0:
4506  new(&m_impl.m_value0) ossia::second_u{other.m_impl.m_value0};
4507  break;
4508  case Type::Type1:
4509  new(&m_impl.m_value1) ossia::bark_u{other.m_impl.m_value1};
4510  break;
4511  case Type::Type2:
4512  new(&m_impl.m_value2) ossia::bpm_u{other.m_impl.m_value2};
4513  break;
4514  case Type::Type3:
4515  new(&m_impl.m_value3) ossia::cent_u{other.m_impl.m_value3};
4516  break;
4517  case Type::Type4:
4518  new(&m_impl.m_value4) ossia::frequency_u{other.m_impl.m_value4};
4519  break;
4520  case Type::Type5:
4521  new(&m_impl.m_value5) ossia::mel_u{other.m_impl.m_value5};
4522  break;
4523  case Type::Type6:
4524  new(&m_impl.m_value6) ossia::midi_pitch_u{other.m_impl.m_value6};
4525  break;
4526  case Type::Type7:
4527  new(&m_impl.m_value7) ossia::millisecond_u{other.m_impl.m_value7};
4528  break;
4529  case Type::Type8:
4530  new(&m_impl.m_value8) ossia::playback_speed_u{other.m_impl.m_value8};
4531  break;
4532  default:
4533  break;
4534  }
4535  }
4536  timing_u(timing_u&& other) noexcept
4537  : m_type{other.m_type}
4538  {
4539  switch(m_type)
4540  {
4541  case Type::Type0:
4542  new(&m_impl.m_value0) ossia::second_u{std::move(other.m_impl.m_value0)};
4543  break;
4544  case Type::Type1:
4545  new(&m_impl.m_value1) ossia::bark_u{std::move(other.m_impl.m_value1)};
4546  break;
4547  case Type::Type2:
4548  new(&m_impl.m_value2) ossia::bpm_u{std::move(other.m_impl.m_value2)};
4549  break;
4550  case Type::Type3:
4551  new(&m_impl.m_value3) ossia::cent_u{std::move(other.m_impl.m_value3)};
4552  break;
4553  case Type::Type4:
4554  new(&m_impl.m_value4) ossia::frequency_u{std::move(other.m_impl.m_value4)};
4555  break;
4556  case Type::Type5:
4557  new(&m_impl.m_value5) ossia::mel_u{std::move(other.m_impl.m_value5)};
4558  break;
4559  case Type::Type6:
4560  new(&m_impl.m_value6) ossia::midi_pitch_u{std::move(other.m_impl.m_value6)};
4561  break;
4562  case Type::Type7:
4563  new(&m_impl.m_value7) ossia::millisecond_u{std::move(other.m_impl.m_value7)};
4564  break;
4565  case Type::Type8:
4566  new(&m_impl.m_value8) ossia::playback_speed_u{std::move(other.m_impl.m_value8)};
4567  break;
4568  default:
4569  break;
4570  }
4571  }
4572  timing_u& operator=(const timing_u& other)
4573  {
4574 
4575  m_type = other.m_type;
4576  switch(m_type)
4577  {
4578  case Type::Type0:
4579  new(&m_impl.m_value0) ossia::second_u{other.m_impl.m_value0};
4580  break;
4581  case Type::Type1:
4582  new(&m_impl.m_value1) ossia::bark_u{other.m_impl.m_value1};
4583  break;
4584  case Type::Type2:
4585  new(&m_impl.m_value2) ossia::bpm_u{other.m_impl.m_value2};
4586  break;
4587  case Type::Type3:
4588  new(&m_impl.m_value3) ossia::cent_u{other.m_impl.m_value3};
4589  break;
4590  case Type::Type4:
4591  new(&m_impl.m_value4) ossia::frequency_u{other.m_impl.m_value4};
4592  break;
4593  case Type::Type5:
4594  new(&m_impl.m_value5) ossia::mel_u{other.m_impl.m_value5};
4595  break;
4596  case Type::Type6:
4597  new(&m_impl.m_value6) ossia::midi_pitch_u{other.m_impl.m_value6};
4598  break;
4599  case Type::Type7:
4600  new(&m_impl.m_value7) ossia::millisecond_u{other.m_impl.m_value7};
4601  break;
4602  case Type::Type8:
4603  new(&m_impl.m_value8) ossia::playback_speed_u{other.m_impl.m_value8};
4604  break;
4605  default:
4606  break;
4607  }
4608  return *this;
4609  }
4610  timing_u& operator=(timing_u&& other) noexcept
4611  {
4612 
4613  m_type = other.m_type;
4614  switch(m_type)
4615  {
4616  case Type::Type0:
4617  new(&m_impl.m_value0) ossia::second_u{std::move(other.m_impl.m_value0)};
4618  break;
4619  case Type::Type1:
4620  new(&m_impl.m_value1) ossia::bark_u{std::move(other.m_impl.m_value1)};
4621  break;
4622  case Type::Type2:
4623  new(&m_impl.m_value2) ossia::bpm_u{std::move(other.m_impl.m_value2)};
4624  break;
4625  case Type::Type3:
4626  new(&m_impl.m_value3) ossia::cent_u{std::move(other.m_impl.m_value3)};
4627  break;
4628  case Type::Type4:
4629  new(&m_impl.m_value4) ossia::frequency_u{std::move(other.m_impl.m_value4)};
4630  break;
4631  case Type::Type5:
4632  new(&m_impl.m_value5) ossia::mel_u{std::move(other.m_impl.m_value5)};
4633  break;
4634  case Type::Type6:
4635  new(&m_impl.m_value6) ossia::midi_pitch_u{std::move(other.m_impl.m_value6)};
4636  break;
4637  case Type::Type7:
4638  new(&m_impl.m_value7) ossia::millisecond_u{std::move(other.m_impl.m_value7)};
4639  break;
4640  case Type::Type8:
4641  new(&m_impl.m_value8) ossia::playback_speed_u{std::move(other.m_impl.m_value8)};
4642  break;
4643  default:
4644  break;
4645  }
4646  return *this;
4647  }
4648 };
4649 template <>
4650 inline const ossia::second_u* timing_u::target() const
4651 {
4652  if(m_type == Type0)
4653  return &m_impl.m_value0;
4654  return nullptr;
4655 }
4656 template <>
4657 inline const ossia::bark_u* timing_u::target() const
4658 {
4659  if(m_type == Type1)
4660  return &m_impl.m_value1;
4661  return nullptr;
4662 }
4663 template <>
4664 inline const ossia::bpm_u* timing_u::target() const
4665 {
4666  if(m_type == Type2)
4667  return &m_impl.m_value2;
4668  return nullptr;
4669 }
4670 template <>
4671 inline const ossia::cent_u* timing_u::target() const
4672 {
4673  if(m_type == Type3)
4674  return &m_impl.m_value3;
4675  return nullptr;
4676 }
4677 template <>
4678 inline const ossia::frequency_u* timing_u::target() const
4679 {
4680  if(m_type == Type4)
4681  return &m_impl.m_value4;
4682  return nullptr;
4683 }
4684 template <>
4685 inline const ossia::mel_u* timing_u::target() const
4686 {
4687  if(m_type == Type5)
4688  return &m_impl.m_value5;
4689  return nullptr;
4690 }
4691 template <>
4692 inline const ossia::midi_pitch_u* timing_u::target() const
4693 {
4694  if(m_type == Type6)
4695  return &m_impl.m_value6;
4696  return nullptr;
4697 }
4698 template <>
4699 inline const ossia::millisecond_u* timing_u::target() const
4700 {
4701  if(m_type == Type7)
4702  return &m_impl.m_value7;
4703  return nullptr;
4704 }
4705 template <>
4706 inline const ossia::playback_speed_u* timing_u::target() const
4707 {
4708  if(m_type == Type8)
4709  return &m_impl.m_value8;
4710  return nullptr;
4711 }
4712 template <>
4713 inline ossia::second_u* timing_u::target()
4714 {
4715  if(m_type == Type0)
4716  return &m_impl.m_value0;
4717  return nullptr;
4718 }
4719 template <>
4720 inline ossia::bark_u* timing_u::target()
4721 {
4722  if(m_type == Type1)
4723  return &m_impl.m_value1;
4724  return nullptr;
4725 }
4726 template <>
4727 inline ossia::bpm_u* timing_u::target()
4728 {
4729  if(m_type == Type2)
4730  return &m_impl.m_value2;
4731  return nullptr;
4732 }
4733 template <>
4734 inline ossia::cent_u* timing_u::target()
4735 {
4736  if(m_type == Type3)
4737  return &m_impl.m_value3;
4738  return nullptr;
4739 }
4740 template <>
4741 inline ossia::frequency_u* timing_u::target()
4742 {
4743  if(m_type == Type4)
4744  return &m_impl.m_value4;
4745  return nullptr;
4746 }
4747 template <>
4748 inline ossia::mel_u* timing_u::target()
4749 {
4750  if(m_type == Type5)
4751  return &m_impl.m_value5;
4752  return nullptr;
4753 }
4754 template <>
4755 inline ossia::midi_pitch_u* timing_u::target()
4756 {
4757  if(m_type == Type6)
4758  return &m_impl.m_value6;
4759  return nullptr;
4760 }
4761 template <>
4762 inline ossia::millisecond_u* timing_u::target()
4763 {
4764  if(m_type == Type7)
4765  return &m_impl.m_value7;
4766  return nullptr;
4767 }
4768 template <>
4769 inline ossia::playback_speed_u* timing_u::target()
4770 {
4771  if(m_type == Type8)
4772  return &m_impl.m_value8;
4773  return nullptr;
4774 }
4775 template <>
4776 inline const ossia::second_u& timing_u::get() const
4777 {
4778  if(m_type == Type0)
4779  return m_impl.m_value0;
4780  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4781 }
4782 template <>
4783 inline const ossia::bark_u& timing_u::get() const
4784 {
4785  if(m_type == Type1)
4786  return m_impl.m_value1;
4787  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4788 }
4789 template <>
4790 inline const ossia::bpm_u& timing_u::get() const
4791 {
4792  if(m_type == Type2)
4793  return m_impl.m_value2;
4794  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4795 }
4796 template <>
4797 inline const ossia::cent_u& timing_u::get() const
4798 {
4799  if(m_type == Type3)
4800  return m_impl.m_value3;
4801  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4802 }
4803 template <>
4804 inline const ossia::frequency_u& timing_u::get() const
4805 {
4806  if(m_type == Type4)
4807  return m_impl.m_value4;
4808  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4809 }
4810 template <>
4811 inline const ossia::mel_u& timing_u::get() const
4812 {
4813  if(m_type == Type5)
4814  return m_impl.m_value5;
4815  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4816 }
4817 template <>
4818 inline const ossia::midi_pitch_u& timing_u::get() const
4819 {
4820  if(m_type == Type6)
4821  return m_impl.m_value6;
4822  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4823 }
4824 template <>
4825 inline const ossia::millisecond_u& timing_u::get() const
4826 {
4827  if(m_type == Type7)
4828  return m_impl.m_value7;
4829  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4830 }
4831 template <>
4832 inline const ossia::playback_speed_u& timing_u::get() const
4833 {
4834  if(m_type == Type8)
4835  return m_impl.m_value8;
4836  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4837 }
4838 template <>
4839 inline ossia::second_u& timing_u::get()
4840 {
4841  if(m_type == Type0)
4842  return m_impl.m_value0;
4843  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4844 }
4845 template <>
4846 inline ossia::bark_u& timing_u::get()
4847 {
4848  if(m_type == Type1)
4849  return m_impl.m_value1;
4850  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4851 }
4852 template <>
4853 inline ossia::bpm_u& timing_u::get()
4854 {
4855  if(m_type == Type2)
4856  return m_impl.m_value2;
4857  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4858 }
4859 template <>
4860 inline ossia::cent_u& timing_u::get()
4861 {
4862  if(m_type == Type3)
4863  return m_impl.m_value3;
4864  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4865 }
4866 template <>
4867 inline ossia::frequency_u& timing_u::get()
4868 {
4869  if(m_type == Type4)
4870  return m_impl.m_value4;
4871  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4872 }
4873 template <>
4874 inline ossia::mel_u& timing_u::get()
4875 {
4876  if(m_type == Type5)
4877  return m_impl.m_value5;
4878  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4879 }
4880 template <>
4881 inline ossia::midi_pitch_u& timing_u::get()
4882 {
4883  if(m_type == Type6)
4884  return m_impl.m_value6;
4885  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4886 }
4887 template <>
4888 inline ossia::millisecond_u& timing_u::get()
4889 {
4890  if(m_type == Type7)
4891  return m_impl.m_value7;
4892  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4893 }
4894 template <>
4895 inline ossia::playback_speed_u& timing_u::get()
4896 {
4897  if(m_type == Type8)
4898  return m_impl.m_value8;
4899  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4900 }
4901 template <typename Visitor>
4902 auto apply_nonnull(Visitor&& functor, const timing_u& var)
4903 {
4904  switch(var.m_type)
4905  {
4906  case timing_u::Type::Type0:
4907  return functor(var.m_impl.m_value0);
4908  case timing_u::Type::Type1:
4909  return functor(var.m_impl.m_value1);
4910  case timing_u::Type::Type2:
4911  return functor(var.m_impl.m_value2);
4912  case timing_u::Type::Type3:
4913  return functor(var.m_impl.m_value3);
4914  case timing_u::Type::Type4:
4915  return functor(var.m_impl.m_value4);
4916  case timing_u::Type::Type5:
4917  return functor(var.m_impl.m_value5);
4918  case timing_u::Type::Type6:
4919  return functor(var.m_impl.m_value6);
4920  case timing_u::Type::Type7:
4921  return functor(var.m_impl.m_value7);
4922  case timing_u::Type::Type8:
4923  return functor(var.m_impl.m_value8);
4924  default:
4925  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4926  }
4927 }
4928 template <typename Visitor>
4929 auto apply_nonnull(Visitor&& functor, timing_u& var)
4930 {
4931  switch(var.m_type)
4932  {
4933  case timing_u::Type::Type0:
4934  return functor(var.m_impl.m_value0);
4935  case timing_u::Type::Type1:
4936  return functor(var.m_impl.m_value1);
4937  case timing_u::Type::Type2:
4938  return functor(var.m_impl.m_value2);
4939  case timing_u::Type::Type3:
4940  return functor(var.m_impl.m_value3);
4941  case timing_u::Type::Type4:
4942  return functor(var.m_impl.m_value4);
4943  case timing_u::Type::Type5:
4944  return functor(var.m_impl.m_value5);
4945  case timing_u::Type::Type6:
4946  return functor(var.m_impl.m_value6);
4947  case timing_u::Type::Type7:
4948  return functor(var.m_impl.m_value7);
4949  case timing_u::Type::Type8:
4950  return functor(var.m_impl.m_value8);
4951  default:
4952  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4953  }
4954 }
4955 template <typename Visitor>
4956 auto apply_nonnull(Visitor&& functor, timing_u&& var)
4957 {
4958  switch(var.m_type)
4959  {
4960  case timing_u::Type::Type0:
4961  return functor(std::move(var.m_impl.m_value0));
4962  case timing_u::Type::Type1:
4963  return functor(std::move(var.m_impl.m_value1));
4964  case timing_u::Type::Type2:
4965  return functor(std::move(var.m_impl.m_value2));
4966  case timing_u::Type::Type3:
4967  return functor(std::move(var.m_impl.m_value3));
4968  case timing_u::Type::Type4:
4969  return functor(std::move(var.m_impl.m_value4));
4970  case timing_u::Type::Type5:
4971  return functor(std::move(var.m_impl.m_value5));
4972  case timing_u::Type::Type6:
4973  return functor(std::move(var.m_impl.m_value6));
4974  case timing_u::Type::Type7:
4975  return functor(std::move(var.m_impl.m_value7));
4976  case timing_u::Type::Type8:
4977  return functor(std::move(var.m_impl.m_value8));
4978  default:
4979  ossia_do_throw(std::runtime_error, "timing_u: bad type");
4980  }
4981 }
4982 template <typename Visitor>
4983 auto apply(Visitor&& functor, const timing_u& var)
4984 {
4985  switch(var.m_type)
4986  {
4987  case timing_u::Type::Type0:
4988  return functor(var.m_impl.m_value0);
4989  case timing_u::Type::Type1:
4990  return functor(var.m_impl.m_value1);
4991  case timing_u::Type::Type2:
4992  return functor(var.m_impl.m_value2);
4993  case timing_u::Type::Type3:
4994  return functor(var.m_impl.m_value3);
4995  case timing_u::Type::Type4:
4996  return functor(var.m_impl.m_value4);
4997  case timing_u::Type::Type5:
4998  return functor(var.m_impl.m_value5);
4999  case timing_u::Type::Type6:
5000  return functor(var.m_impl.m_value6);
5001  case timing_u::Type::Type7:
5002  return functor(var.m_impl.m_value7);
5003  case timing_u::Type::Type8:
5004  return functor(var.m_impl.m_value8);
5005  default:
5006  return functor();
5007  }
5008 }
5009 template <typename Visitor>
5010 auto apply(Visitor&& functor, timing_u& var)
5011 {
5012  switch(var.m_type)
5013  {
5014  case timing_u::Type::Type0:
5015  return functor(var.m_impl.m_value0);
5016  case timing_u::Type::Type1:
5017  return functor(var.m_impl.m_value1);
5018  case timing_u::Type::Type2:
5019  return functor(var.m_impl.m_value2);
5020  case timing_u::Type::Type3:
5021  return functor(var.m_impl.m_value3);
5022  case timing_u::Type::Type4:
5023  return functor(var.m_impl.m_value4);
5024  case timing_u::Type::Type5:
5025  return functor(var.m_impl.m_value5);
5026  case timing_u::Type::Type6:
5027  return functor(var.m_impl.m_value6);
5028  case timing_u::Type::Type7:
5029  return functor(var.m_impl.m_value7);
5030  case timing_u::Type::Type8:
5031  return functor(var.m_impl.m_value8);
5032  default:
5033  return functor();
5034  }
5035 }
5036 template <typename Visitor>
5037 auto apply(Visitor&& functor, timing_u&& var)
5038 {
5039  switch(var.m_type)
5040  {
5041  case timing_u::Type::Type0:
5042  return functor(std::move(var.m_impl.m_value0));
5043  case timing_u::Type::Type1:
5044  return functor(std::move(var.m_impl.m_value1));
5045  case timing_u::Type::Type2:
5046  return functor(std::move(var.m_impl.m_value2));
5047  case timing_u::Type::Type3:
5048  return functor(std::move(var.m_impl.m_value3));
5049  case timing_u::Type::Type4:
5050  return functor(std::move(var.m_impl.m_value4));
5051  case timing_u::Type::Type5:
5052  return functor(std::move(var.m_impl.m_value5));
5053  case timing_u::Type::Type6:
5054  return functor(std::move(var.m_impl.m_value6));
5055  case timing_u::Type::Type7:
5056  return functor(std::move(var.m_impl.m_value7));
5057  case timing_u::Type::Type8:
5058  return functor(std::move(var.m_impl.m_value8));
5059  default:
5060  return functor();
5061  }
5062 }
5063 inline bool operator==(const timing_u& lhs, const timing_u& rhs)
5064 {
5065  return (lhs.m_type == rhs.m_type);
5066 }
5067 inline bool operator!=(const timing_u& lhs, const timing_u& rhs)
5068 {
5069  return (lhs.m_type != rhs.m_type);
5070 }
5071 inline bool operator==(const timing_u& lhs, const ossia::second_u& rhs)
5072 {
5073  return (lhs.m_type == timing_u::Type::Type0);
5074 }
5075 inline bool operator==(const ossia::second_u& lhs, const timing_u& rhs)
5076 {
5077  return (rhs.m_type == timing_u::Type::Type0);
5078 }
5079 inline bool operator!=(const timing_u& lhs, const ossia::second_u& rhs)
5080 {
5081  return (lhs.m_type != timing_u::Type::Type0);
5082 }
5083 inline bool operator!=(const ossia::second_u& lhs, const timing_u& rhs)
5084 {
5085  return (rhs.m_type != timing_u::Type::Type0);
5086 }
5087 inline bool operator==(const timing_u& lhs, const ossia::bark_u& rhs)
5088 {
5089  return (lhs.m_type == timing_u::Type::Type1);
5090 }
5091 inline bool operator==(const ossia::bark_u& lhs, const timing_u& rhs)
5092 {
5093  return (rhs.m_type == timing_u::Type::Type1);
5094 }
5095 inline bool operator!=(const timing_u& lhs, const ossia::bark_u& rhs)
5096 {
5097  return (lhs.m_type != timing_u::Type::Type1);
5098 }
5099 inline bool operator!=(const ossia::bark_u& lhs, const timing_u& rhs)
5100 {
5101  return (rhs.m_type != timing_u::Type::Type1);
5102 }
5103 inline bool operator==(const timing_u& lhs, const ossia::bpm_u& rhs)
5104 {
5105  return (lhs.m_type == timing_u::Type::Type2);
5106 }
5107 inline bool operator==(const ossia::bpm_u& lhs, const timing_u& rhs)
5108 {
5109  return (rhs.m_type == timing_u::Type::Type2);
5110 }
5111 inline bool operator!=(const timing_u& lhs, const ossia::bpm_u& rhs)
5112 {
5113  return (lhs.m_type != timing_u::Type::Type2);
5114 }
5115 inline bool operator!=(const ossia::bpm_u& lhs, const timing_u& rhs)
5116 {
5117  return (rhs.m_type != timing_u::Type::Type2);
5118 }
5119 inline bool operator==(const timing_u& lhs, const ossia::cent_u& rhs)
5120 {
5121  return (lhs.m_type == timing_u::Type::Type3);
5122 }
5123 inline bool operator==(const ossia::cent_u& lhs, const timing_u& rhs)
5124 {
5125  return (rhs.m_type == timing_u::Type::Type3);
5126 }
5127 inline bool operator!=(const timing_u& lhs, const ossia::cent_u& rhs)
5128 {
5129  return (lhs.m_type != timing_u::Type::Type3);
5130 }
5131 inline bool operator!=(const ossia::cent_u& lhs, const timing_u& rhs)
5132 {
5133  return (rhs.m_type != timing_u::Type::Type3);
5134 }
5135 inline bool operator==(const timing_u& lhs, const ossia::frequency_u& rhs)
5136 {
5137  return (lhs.m_type == timing_u::Type::Type4);
5138 }
5139 inline bool operator==(const ossia::frequency_u& lhs, const timing_u& rhs)
5140 {
5141  return (rhs.m_type == timing_u::Type::Type4);
5142 }
5143 inline bool operator!=(const timing_u& lhs, const ossia::frequency_u& rhs)
5144 {
5145  return (lhs.m_type != timing_u::Type::Type4);
5146 }
5147 inline bool operator!=(const ossia::frequency_u& lhs, const timing_u& rhs)
5148 {
5149  return (rhs.m_type != timing_u::Type::Type4);
5150 }
5151 inline bool operator==(const timing_u& lhs, const ossia::mel_u& rhs)
5152 {
5153  return (lhs.m_type == timing_u::Type::Type5);
5154 }
5155 inline bool operator==(const ossia::mel_u& lhs, const timing_u& rhs)
5156 {
5157  return (rhs.m_type == timing_u::Type::Type5);
5158 }
5159 inline bool operator!=(const timing_u& lhs, const ossia::mel_u& rhs)
5160 {
5161  return (lhs.m_type != timing_u::Type::Type5);
5162 }
5163 inline bool operator!=(const ossia::mel_u& lhs, const timing_u& rhs)
5164 {
5165  return (rhs.m_type != timing_u::Type::Type5);
5166 }
5167 inline bool operator==(const timing_u& lhs, const ossia::midi_pitch_u& rhs)
5168 {
5169  return (lhs.m_type == timing_u::Type::Type6);
5170 }
5171 inline bool operator==(const ossia::midi_pitch_u& lhs, const timing_u& rhs)
5172 {
5173  return (rhs.m_type == timing_u::Type::Type6);
5174 }
5175 inline bool operator!=(const timing_u& lhs, const ossia::midi_pitch_u& rhs)
5176 {
5177  return (lhs.m_type != timing_u::Type::Type6);
5178 }
5179 inline bool operator!=(const ossia::midi_pitch_u& lhs, const timing_u& rhs)
5180 {
5181  return (rhs.m_type != timing_u::Type::Type6);
5182 }
5183 inline bool operator==(const timing_u& lhs, const ossia::millisecond_u& rhs)
5184 {
5185  return (lhs.m_type == timing_u::Type::Type7);
5186 }
5187 inline bool operator==(const ossia::millisecond_u& lhs, const timing_u& rhs)
5188 {
5189  return (rhs.m_type == timing_u::Type::Type7);
5190 }
5191 inline bool operator!=(const timing_u& lhs, const ossia::millisecond_u& rhs)
5192 {
5193  return (lhs.m_type != timing_u::Type::Type7);
5194 }
5195 inline bool operator!=(const ossia::millisecond_u& lhs, const timing_u& rhs)
5196 {
5197  return (rhs.m_type != timing_u::Type::Type7);
5198 }
5199 inline bool operator==(const timing_u& lhs, const ossia::playback_speed_u& rhs)
5200 {
5201  return (lhs.m_type == timing_u::Type::Type8);
5202 }
5203 inline bool operator==(const ossia::playback_speed_u& lhs, const timing_u& rhs)
5204 {
5205  return (rhs.m_type == timing_u::Type::Type8);
5206 }
5207 inline bool operator!=(const timing_u& lhs, const ossia::playback_speed_u& rhs)
5208 {
5209  return (lhs.m_type != timing_u::Type::Type8);
5210 }
5211 inline bool operator!=(const ossia::playback_speed_u& lhs, const timing_u& rhs)
5212 {
5213  return (rhs.m_type != timing_u::Type::Type8);
5214 }
5215 struct unit_variant
5216 {
5217 public:
5218  struct dummy_t
5219  {
5220  };
5221  union Impl
5222  {
5223  ossia::distance_u m_value0;
5224 
5225  ossia::position_u m_value1;
5226 
5227  ossia::speed_u m_value2;
5228 
5229  ossia::orientation_u m_value3;
5230 
5231  ossia::angle_u m_value4;
5232 
5233  ossia::color_u m_value5;
5234 
5235  ossia::gain_u m_value6;
5236 
5237  ossia::timing_u m_value7;
5238 
5239  dummy_t m_dummy;
5240  Impl()
5241  : m_dummy{}
5242  {
5243  }
5244  ~Impl() = default;
5245  };
5246 
5247  enum Type : int8_t
5248  {
5249  Type0,
5250  Type1,
5251  Type2,
5252  Type3,
5253  Type4,
5254  Type5,
5255  Type6,
5256  Type7,
5258  };
5259 
5260  Impl m_impl;
5261  Type m_type;
5262 
5263 public:
5264  static const constexpr auto npos = Npos;
5265  int which() const noexcept { return m_type; }
5266 
5267  operator bool() const noexcept { return m_type != npos; }
5268  template <typename T>
5269  const T* target() const;
5270  template <typename T>
5271  T* target();
5272  template <typename T>
5273  const T& get() const;
5274  template <typename T>
5275  T& get();
5276 
5277  template <typename T>
5278  static Type matching_type();
5279  unit_variant() noexcept
5280  : m_type{Npos}
5281  {
5282  }
5283  ~unit_variant() noexcept { }
5284  unit_variant(ossia::distance_u v) noexcept
5285  : m_type{Type0}
5286  {
5287  new(&m_impl.m_value0) ossia::distance_u{v};
5288  }
5289  unit_variant(ossia::position_u v) noexcept
5290  : m_type{Type1}
5291  {
5292  new(&m_impl.m_value1) ossia::position_u{v};
5293  }
5294  unit_variant(ossia::speed_u v) noexcept
5295  : m_type{Type2}
5296  {
5297  new(&m_impl.m_value2) ossia::speed_u{v};
5298  }
5299  unit_variant(ossia::orientation_u v) noexcept
5300  : m_type{Type3}
5301  {
5302  new(&m_impl.m_value3) ossia::orientation_u{v};
5303  }
5304  unit_variant(ossia::angle_u v) noexcept
5305  : m_type{Type4}
5306  {
5307  new(&m_impl.m_value4) ossia::angle_u{v};
5308  }
5309  unit_variant(ossia::color_u v) noexcept
5310  : m_type{Type5}
5311  {
5312  new(&m_impl.m_value5) ossia::color_u{v};
5313  }
5314  unit_variant(ossia::gain_u v) noexcept
5315  : m_type{Type6}
5316  {
5317  new(&m_impl.m_value6) ossia::gain_u{v};
5318  }
5319  unit_variant(ossia::timing_u v) noexcept
5320  : m_type{Type7}
5321  {
5322  new(&m_impl.m_value7) ossia::timing_u{v};
5323  }
5324  unit_variant(const unit_variant& other) noexcept
5325  : m_type{other.m_type}
5326  {
5327  switch(m_type)
5328  {
5329  case Type::Type0:
5330  new(&m_impl.m_value0) ossia::distance_u{other.m_impl.m_value0};
5331  break;
5332  case Type::Type1:
5333  new(&m_impl.m_value1) ossia::position_u{other.m_impl.m_value1};
5334  break;
5335  case Type::Type2:
5336  new(&m_impl.m_value2) ossia::speed_u{other.m_impl.m_value2};
5337  break;
5338  case Type::Type3:
5339  new(&m_impl.m_value3) ossia::orientation_u{other.m_impl.m_value3};
5340  break;
5341  case Type::Type4:
5342  new(&m_impl.m_value4) ossia::angle_u{other.m_impl.m_value4};
5343  break;
5344  case Type::Type5:
5345  new(&m_impl.m_value5) ossia::color_u{other.m_impl.m_value5};
5346  break;
5347  case Type::Type6:
5348  new(&m_impl.m_value6) ossia::gain_u{other.m_impl.m_value6};
5349  break;
5350  case Type::Type7:
5351  new(&m_impl.m_value7) ossia::timing_u{other.m_impl.m_value7};
5352  break;
5353  default:
5354  break;
5355  }
5356  }
5357  unit_variant(unit_variant&& other) noexcept
5358  : m_type{other.m_type}
5359  {
5360  switch(m_type)
5361  {
5362  case Type::Type0:
5363  new(&m_impl.m_value0) ossia::distance_u{std::move(other.m_impl.m_value0)};
5364  break;
5365  case Type::Type1:
5366  new(&m_impl.m_value1) ossia::position_u{std::move(other.m_impl.m_value1)};
5367  break;
5368  case Type::Type2:
5369  new(&m_impl.m_value2) ossia::speed_u{std::move(other.m_impl.m_value2)};
5370  break;
5371  case Type::Type3:
5372  new(&m_impl.m_value3) ossia::orientation_u{std::move(other.m_impl.m_value3)};
5373  break;
5374  case Type::Type4:
5375  new(&m_impl.m_value4) ossia::angle_u{std::move(other.m_impl.m_value4)};
5376  break;
5377  case Type::Type5:
5378  new(&m_impl.m_value5) ossia::color_u{std::move(other.m_impl.m_value5)};
5379  break;
5380  case Type::Type6:
5381  new(&m_impl.m_value6) ossia::gain_u{std::move(other.m_impl.m_value6)};
5382  break;
5383  case Type::Type7:
5384  new(&m_impl.m_value7) ossia::timing_u{std::move(other.m_impl.m_value7)};
5385  break;
5386  default:
5387  break;
5388  }
5389  }
5390  unit_variant& operator=(const unit_variant& other) noexcept
5391  {
5392 
5393  m_type = other.m_type;
5394  switch(m_type)
5395  {
5396  case Type::Type0:
5397  new(&m_impl.m_value0) ossia::distance_u{other.m_impl.m_value0};
5398  break;
5399  case Type::Type1:
5400  new(&m_impl.m_value1) ossia::position_u{other.m_impl.m_value1};
5401  break;
5402  case Type::Type2:
5403  new(&m_impl.m_value2) ossia::speed_u{other.m_impl.m_value2};
5404  break;
5405  case Type::Type3:
5406  new(&m_impl.m_value3) ossia::orientation_u{other.m_impl.m_value3};
5407  break;
5408  case Type::Type4:
5409  new(&m_impl.m_value4) ossia::angle_u{other.m_impl.m_value4};
5410  break;
5411  case Type::Type5:
5412  new(&m_impl.m_value5) ossia::color_u{other.m_impl.m_value5};
5413  break;
5414  case Type::Type6:
5415  new(&m_impl.m_value6) ossia::gain_u{other.m_impl.m_value6};
5416  break;
5417  case Type::Type7:
5418  new(&m_impl.m_value7) ossia::timing_u{other.m_impl.m_value7};
5419  break;
5420  default:
5421  break;
5422  }
5423  return *this;
5424  }
5425  unit_variant& operator=(unit_variant&& other) noexcept
5426  {
5427 
5428  m_type = other.m_type;
5429  switch(m_type)
5430  {
5431  case Type::Type0:
5432  new(&m_impl.m_value0) ossia::distance_u{std::move(other.m_impl.m_value0)};
5433  break;
5434  case Type::Type1:
5435  new(&m_impl.m_value1) ossia::position_u{std::move(other.m_impl.m_value1)};
5436  break;
5437  case Type::Type2:
5438  new(&m_impl.m_value2) ossia::speed_u{std::move(other.m_impl.m_value2)};
5439  break;
5440  case Type::Type3:
5441  new(&m_impl.m_value3) ossia::orientation_u{std::move(other.m_impl.m_value3)};
5442  break;
5443  case Type::Type4:
5444  new(&m_impl.m_value4) ossia::angle_u{std::move(other.m_impl.m_value4)};
5445  break;
5446  case Type::Type5:
5447  new(&m_impl.m_value5) ossia::color_u{std::move(other.m_impl.m_value5)};
5448  break;
5449  case Type::Type6:
5450  new(&m_impl.m_value6) ossia::gain_u{std::move(other.m_impl.m_value6)};
5451  break;
5452  case Type::Type7:
5453  new(&m_impl.m_value7) ossia::timing_u{std::move(other.m_impl.m_value7)};
5454  break;
5455  default:
5456  break;
5457  }
5458  return *this;
5459  }
5460 };
5461 template <>
5462 inline const ossia::distance_u* unit_variant::target() const
5463 {
5464  if(m_type == Type0)
5465  return &m_impl.m_value0;
5466  return nullptr;
5467 }
5468 template <>
5469 inline const ossia::position_u* unit_variant::target() const
5470 {
5471  if(m_type == Type1)
5472  return &m_impl.m_value1;
5473  return nullptr;
5474 }
5475 template <>
5476 inline const ossia::speed_u* unit_variant::target() const
5477 {
5478  if(m_type == Type2)
5479  return &m_impl.m_value2;
5480  return nullptr;
5481 }
5482 template <>
5483 inline const ossia::orientation_u* unit_variant::target() const
5484 {
5485  if(m_type == Type3)
5486  return &m_impl.m_value3;
5487  return nullptr;
5488 }
5489 template <>
5490 inline const ossia::angle_u* unit_variant::target() const
5491 {
5492  if(m_type == Type4)
5493  return &m_impl.m_value4;
5494  return nullptr;
5495 }
5496 template <>
5497 inline const ossia::color_u* unit_variant::target() const
5498 {
5499  if(m_type == Type5)
5500  return &m_impl.m_value5;
5501  return nullptr;
5502 }
5503 template <>
5504 inline const ossia::gain_u* unit_variant::target() const
5505 {
5506  if(m_type == Type6)
5507  return &m_impl.m_value6;
5508  return nullptr;
5509 }
5510 template <>
5511 inline const ossia::timing_u* unit_variant::target() const
5512 {
5513  if(m_type == Type7)
5514  return &m_impl.m_value7;
5515  return nullptr;
5516 }
5517 template <>
5518 inline ossia::distance_u* unit_variant::target()
5519 {
5520  if(m_type == Type0)
5521  return &m_impl.m_value0;
5522  return nullptr;
5523 }
5524 template <>
5525 inline ossia::position_u* unit_variant::target()
5526 {
5527  if(m_type == Type1)
5528  return &m_impl.m_value1;
5529  return nullptr;
5530 }
5531 template <>
5532 inline ossia::speed_u* unit_variant::target()
5533 {
5534  if(m_type == Type2)
5535  return &m_impl.m_value2;
5536  return nullptr;
5537 }
5538 template <>
5539 inline ossia::orientation_u* unit_variant::target()
5540 {
5541  if(m_type == Type3)
5542  return &m_impl.m_value3;
5543  return nullptr;
5544 }
5545 template <>
5546 inline ossia::angle_u* unit_variant::target()
5547 {
5548  if(m_type == Type4)
5549  return &m_impl.m_value4;
5550  return nullptr;
5551 }
5552 template <>
5553 inline ossia::color_u* unit_variant::target()
5554 {
5555  if(m_type == Type5)
5556  return &m_impl.m_value5;
5557  return nullptr;
5558 }
5559 template <>
5560 inline ossia::gain_u* unit_variant::target()
5561 {
5562  if(m_type == Type6)
5563  return &m_impl.m_value6;
5564  return nullptr;
5565 }
5566 template <>
5567 inline ossia::timing_u* unit_variant::target()
5568 {
5569  if(m_type == Type7)
5570  return &m_impl.m_value7;
5571  return nullptr;
5572 }
5573 template <>
5574 inline const ossia::distance_u& unit_variant::get() const
5575 {
5576  if(m_type == Type0)
5577  return m_impl.m_value0;
5578  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5579 }
5580 template <>
5581 inline const ossia::position_u& unit_variant::get() const
5582 {
5583  if(m_type == Type1)
5584  return m_impl.m_value1;
5585  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5586 }
5587 template <>
5588 inline const ossia::speed_u& unit_variant::get() const
5589 {
5590  if(m_type == Type2)
5591  return m_impl.m_value2;
5592  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5593 }
5594 template <>
5595 inline const ossia::orientation_u& unit_variant::get() const
5596 {
5597  if(m_type == Type3)
5598  return m_impl.m_value3;
5599  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5600 }
5601 template <>
5602 inline const ossia::angle_u& unit_variant::get() const
5603 {
5604  if(m_type == Type4)
5605  return m_impl.m_value4;
5606  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5607 }
5608 template <>
5609 inline const ossia::color_u& unit_variant::get() const
5610 {
5611  if(m_type == Type5)
5612  return m_impl.m_value5;
5613  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5614 }
5615 template <>
5616 inline const ossia::gain_u& unit_variant::get() const
5617 {
5618  if(m_type == Type6)
5619  return m_impl.m_value6;
5620  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5621 }
5622 template <>
5623 inline const ossia::timing_u& unit_variant::get() const
5624 {
5625  if(m_type == Type7)
5626  return m_impl.m_value7;
5627  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5628 }
5629 template <>
5630 inline ossia::distance_u& unit_variant::get()
5631 {
5632  if(m_type == Type0)
5633  return m_impl.m_value0;
5634  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5635 }
5636 template <>
5637 inline ossia::position_u& unit_variant::get()
5638 {
5639  if(m_type == Type1)
5640  return m_impl.m_value1;
5641  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5642 }
5643 template <>
5644 inline ossia::speed_u& unit_variant::get()
5645 {
5646  if(m_type == Type2)
5647  return m_impl.m_value2;
5648  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5649 }
5650 template <>
5651 inline ossia::orientation_u& unit_variant::get()
5652 {
5653  if(m_type == Type3)
5654  return m_impl.m_value3;
5655  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5656 }
5657 template <>
5658 inline ossia::angle_u& unit_variant::get()
5659 {
5660  if(m_type == Type4)
5661  return m_impl.m_value4;
5662  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5663 }
5664 template <>
5665 inline ossia::color_u& unit_variant::get()
5666 {
5667  if(m_type == Type5)
5668  return m_impl.m_value5;
5669  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5670 }
5671 template <>
5672 inline ossia::gain_u& unit_variant::get()
5673 {
5674  if(m_type == Type6)
5675  return m_impl.m_value6;
5676  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5677 }
5678 template <>
5679 inline ossia::timing_u& unit_variant::get()
5680 {
5681  if(m_type == Type7)
5682  return m_impl.m_value7;
5683  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5684 }
5685 template <typename Visitor>
5686 auto apply_nonnull(Visitor&& functor, const unit_variant& var)
5687 {
5688  switch(var.m_type)
5689  {
5690  case unit_variant::Type::Type0:
5691  return functor(var.m_impl.m_value0);
5692  case unit_variant::Type::Type1:
5693  return functor(var.m_impl.m_value1);
5694  case unit_variant::Type::Type2:
5695  return functor(var.m_impl.m_value2);
5696  case unit_variant::Type::Type3:
5697  return functor(var.m_impl.m_value3);
5698  case unit_variant::Type::Type4:
5699  return functor(var.m_impl.m_value4);
5700  case unit_variant::Type::Type5:
5701  return functor(var.m_impl.m_value5);
5702  case unit_variant::Type::Type6:
5703  return functor(var.m_impl.m_value6);
5704  case unit_variant::Type::Type7:
5705  return functor(var.m_impl.m_value7);
5706  default:
5707  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5708  }
5709 }
5710 template <typename Visitor>
5711 auto apply_nonnull(Visitor&& functor, unit_variant& var)
5712 {
5713  switch(var.m_type)
5714  {
5715  case unit_variant::Type::Type0:
5716  return functor(var.m_impl.m_value0);
5717  case unit_variant::Type::Type1:
5718  return functor(var.m_impl.m_value1);
5719  case unit_variant::Type::Type2:
5720  return functor(var.m_impl.m_value2);
5721  case unit_variant::Type::Type3:
5722  return functor(var.m_impl.m_value3);
5723  case unit_variant::Type::Type4:
5724  return functor(var.m_impl.m_value4);
5725  case unit_variant::Type::Type5:
5726  return functor(var.m_impl.m_value5);
5727  case unit_variant::Type::Type6:
5728  return functor(var.m_impl.m_value6);
5729  case unit_variant::Type::Type7:
5730  return functor(var.m_impl.m_value7);
5731  default:
5732  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5733  }
5734 }
5735 template <typename Visitor>
5736 auto apply_nonnull(Visitor&& functor, unit_variant&& var)
5737 {
5738  switch(var.m_type)
5739  {
5740  case unit_variant::Type::Type0:
5741  return functor(std::move(var.m_impl.m_value0));
5742  case unit_variant::Type::Type1:
5743  return functor(std::move(var.m_impl.m_value1));
5744  case unit_variant::Type::Type2:
5745  return functor(std::move(var.m_impl.m_value2));
5746  case unit_variant::Type::Type3:
5747  return functor(std::move(var.m_impl.m_value3));
5748  case unit_variant::Type::Type4:
5749  return functor(std::move(var.m_impl.m_value4));
5750  case unit_variant::Type::Type5:
5751  return functor(std::move(var.m_impl.m_value5));
5752  case unit_variant::Type::Type6:
5753  return functor(std::move(var.m_impl.m_value6));
5754  case unit_variant::Type::Type7:
5755  return functor(std::move(var.m_impl.m_value7));
5756  default:
5757  ossia_do_throw(std::runtime_error, "unit_variant: bad type");
5758  }
5759 }
5760 template <typename Visitor>
5761 auto apply(Visitor&& functor, const unit_variant& var)
5762 {
5763  switch(var.m_type)
5764  {
5765  case unit_variant::Type::Type0:
5766  return functor(var.m_impl.m_value0);
5767  case unit_variant::Type::Type1:
5768  return functor(var.m_impl.m_value1);
5769  case unit_variant::Type::Type2:
5770  return functor(var.m_impl.m_value2);
5771  case unit_variant::Type::Type3:
5772  return functor(var.m_impl.m_value3);
5773  case unit_variant::Type::Type4:
5774  return functor(var.m_impl.m_value4);
5775  case unit_variant::Type::Type5:
5776  return functor(var.m_impl.m_value5);
5777  case unit_variant::Type::Type6:
5778  return functor(var.m_impl.m_value6);
5779  case unit_variant::Type::Type7:
5780  return functor(var.m_impl.m_value7);
5781  default:
5782  return functor();
5783  }
5784 }
5785 template <typename Visitor>
5786 auto apply(Visitor&& functor, unit_variant& var)
5787 {
5788  switch(var.m_type)
5789  {
5790  case unit_variant::Type::Type0:
5791  return functor(var.m_impl.m_value0);
5792  case unit_variant::Type::Type1:
5793  return functor(var.m_impl.m_value1);
5794  case unit_variant::Type::Type2:
5795  return functor(var.m_impl.m_value2);
5796  case unit_variant::Type::Type3:
5797  return functor(var.m_impl.m_value3);
5798  case unit_variant::Type::Type4:
5799  return functor(var.m_impl.m_value4);
5800  case unit_variant::Type::Type5:
5801  return functor(var.m_impl.m_value5);
5802  case unit_variant::Type::Type6:
5803  return functor(var.m_impl.m_value6);
5804  case unit_variant::Type::Type7:
5805  return functor(var.m_impl.m_value7);
5806  default:
5807  return functor();
5808  }
5809 }
5810 template <typename Visitor>
5811 auto apply(Visitor&& functor, unit_variant&& var)
5812 {
5813  switch(var.m_type)
5814  {
5815  case unit_variant::Type::Type0:
5816  return functor(std::move(var.m_impl.m_value0));
5817  case unit_variant::Type::Type1:
5818  return functor(std::move(var.m_impl.m_value1));
5819  case unit_variant::Type::Type2:
5820  return functor(std::move(var.m_impl.m_value2));
5821  case unit_variant::Type::Type3:
5822  return functor(std::move(var.m_impl.m_value3));
5823  case unit_variant::Type::Type4:
5824  return functor(std::move(var.m_impl.m_value4));
5825  case unit_variant::Type::Type5:
5826  return functor(std::move(var.m_impl.m_value5));
5827  case unit_variant::Type::Type6:
5828  return functor(std::move(var.m_impl.m_value6));
5829  case unit_variant::Type::Type7:
5830  return functor(std::move(var.m_impl.m_value7));
5831  default:
5832  return functor();
5833  }
5834 }
5835 inline bool operator==(const unit_variant& lhs, const unit_variant& rhs)
5836 {
5837  if(lhs.m_type == rhs.m_type)
5838  {
5839  switch(lhs.m_type)
5840  {
5841  case unit_variant::Type::Type0:
5842  return lhs.m_impl.m_value0 == rhs.m_impl.m_value0;
5843  case unit_variant::Type::Type1:
5844  return lhs.m_impl.m_value1 == rhs.m_impl.m_value1;
5845  case unit_variant::Type::Type2:
5846  return lhs.m_impl.m_value2 == rhs.m_impl.m_value2;
5847  case unit_variant::Type::Type3:
5848  return lhs.m_impl.m_value3 == rhs.m_impl.m_value3;
5849  case unit_variant::Type::Type4:
5850  return lhs.m_impl.m_value4 == rhs.m_impl.m_value4;
5851  case unit_variant::Type::Type5:
5852  return lhs.m_impl.m_value5 == rhs.m_impl.m_value5;
5853  case unit_variant::Type::Type6:
5854  return lhs.m_impl.m_value6 == rhs.m_impl.m_value6;
5855  case unit_variant::Type::Type7:
5856  return lhs.m_impl.m_value7 == rhs.m_impl.m_value7;
5857  default:
5858  return true;
5859  }
5860  }
5861  return false;
5862 }
5863 inline bool operator!=(const unit_variant& lhs, const unit_variant& rhs)
5864 {
5865  if(lhs.m_type != rhs.m_type)
5866  return true;
5867  switch(lhs.m_type)
5868  {
5869  case unit_variant::Type::Type0:
5870  return lhs.m_impl.m_value0 != rhs.m_impl.m_value0;
5871  case unit_variant::Type::Type1:
5872  return lhs.m_impl.m_value1 != rhs.m_impl.m_value1;
5873  case unit_variant::Type::Type2:
5874  return lhs.m_impl.m_value2 != rhs.m_impl.m_value2;
5875  case unit_variant::Type::Type3:
5876  return lhs.m_impl.m_value3 != rhs.m_impl.m_value3;
5877  case unit_variant::Type::Type4:
5878  return lhs.m_impl.m_value4 != rhs.m_impl.m_value4;
5879  case unit_variant::Type::Type5:
5880  return lhs.m_impl.m_value5 != rhs.m_impl.m_value5;
5881  case unit_variant::Type::Type6:
5882  return lhs.m_impl.m_value6 != rhs.m_impl.m_value6;
5883  case unit_variant::Type::Type7:
5884  return lhs.m_impl.m_value7 != rhs.m_impl.m_value7;
5885  default:
5886  return false;
5887  }
5888  return true;
5889 }
5890 inline bool operator==(const unit_variant& lhs, const ossia::distance_u& rhs)
5891 {
5892  return (lhs.m_type == unit_variant::Type::Type0) && (lhs.m_impl.m_value0 == rhs);
5893 }
5894 inline bool operator==(const ossia::distance_u& lhs, const unit_variant& rhs)
5895 {
5896  return (rhs.m_type == unit_variant::Type::Type0) && (rhs.m_impl.m_value0 == lhs);
5897 }
5898 inline bool operator!=(const unit_variant& lhs, const ossia::distance_u& rhs)
5899 {
5900  return (lhs.m_type != unit_variant::Type::Type0) || (lhs.m_impl.m_value0 != rhs);
5901 }
5902 inline bool operator!=(const ossia::distance_u& lhs, const unit_variant& rhs)
5903 {
5904  return (rhs.m_type != unit_variant::Type::Type0) || (rhs.m_impl.m_value0 != lhs);
5905 }
5906 inline bool operator==(const unit_variant& lhs, const ossia::position_u& rhs)
5907 {
5908  return (lhs.m_type == unit_variant::Type::Type1) && (lhs.m_impl.m_value1 == rhs);
5909 }
5910 inline bool operator==(const ossia::position_u& lhs, const unit_variant& rhs)
5911 {
5912  return (rhs.m_type == unit_variant::Type::Type1) && (rhs.m_impl.m_value1 == lhs);
5913 }
5914 inline bool operator!=(const unit_variant& lhs, const ossia::position_u& rhs)
5915 {
5916  return (lhs.m_type != unit_variant::Type::Type1) || (lhs.m_impl.m_value1 != rhs);
5917 }
5918 inline bool operator!=(const ossia::position_u& lhs, const unit_variant& rhs)
5919 {
5920  return (rhs.m_type != unit_variant::Type::Type1) || (rhs.m_impl.m_value1 != lhs);
5921 }
5922 inline bool operator==(const unit_variant& lhs, const ossia::speed_u& rhs)
5923 {
5924  return (lhs.m_type == unit_variant::Type::Type2) && (lhs.m_impl.m_value2 == rhs);
5925 }
5926 inline bool operator==(const ossia::speed_u& lhs, const unit_variant& rhs)
5927 {
5928  return (rhs.m_type == unit_variant::Type::Type2) && (rhs.m_impl.m_value2 == lhs);
5929 }
5930 inline bool operator!=(const unit_variant& lhs, const ossia::speed_u& rhs)
5931 {
5932  return (lhs.m_type != unit_variant::Type::Type2) || (lhs.m_impl.m_value2 != rhs);
5933 }
5934 inline bool operator!=(const ossia::speed_u& lhs, const unit_variant& rhs)
5935 {
5936  return (rhs.m_type != unit_variant::Type::Type2) || (rhs.m_impl.m_value2 != lhs);
5937 }
5938 inline bool operator==(const unit_variant& lhs, const ossia::orientation_u& rhs)
5939 {
5940  return (lhs.m_type == unit_variant::Type::Type3) && (lhs.m_impl.m_value3 == rhs);
5941 }
5942 inline bool operator==(const ossia::orientation_u& lhs, const unit_variant& rhs)
5943 {
5944  return (rhs.m_type == unit_variant::Type::Type3) && (rhs.m_impl.m_value3 == lhs);
5945 }
5946 inline bool operator!=(const unit_variant& lhs, const ossia::orientation_u& rhs)
5947 {
5948  return (lhs.m_type != unit_variant::Type::Type3) || (lhs.m_impl.m_value3 != rhs);
5949 }
5950 inline bool operator!=(const ossia::orientation_u& lhs, const unit_variant& rhs)
5951 {
5952  return (rhs.m_type != unit_variant::Type::Type3) || (rhs.m_impl.m_value3 != lhs);
5953 }
5954 inline bool operator==(const unit_variant& lhs, const ossia::angle_u& rhs)
5955 {
5956  return (lhs.m_type == unit_variant::Type::Type4) && (lhs.m_impl.m_value4 == rhs);
5957 }
5958 inline bool operator==(const ossia::angle_u& lhs, const unit_variant& rhs)
5959 {
5960  return (rhs.m_type == unit_variant::Type::Type4) && (rhs.m_impl.m_value4 == lhs);
5961 }
5962 inline bool operator!=(const unit_variant& lhs, const ossia::angle_u& rhs)
5963 {
5964  return (lhs.m_type != unit_variant::Type::Type4) || (lhs.m_impl.m_value4 != rhs);
5965 }
5966 inline bool operator!=(const ossia::angle_u& lhs, const unit_variant& rhs)
5967 {
5968  return (rhs.m_type != unit_variant::Type::Type4) || (rhs.m_impl.m_value4 != lhs);
5969 }
5970 inline bool operator==(const unit_variant& lhs, const ossia::color_u& rhs)
5971 {
5972  return (lhs.m_type == unit_variant::Type::Type5) && (lhs.m_impl.m_value5 == rhs);
5973 }
5974 inline bool operator==(const ossia::color_u& lhs, const unit_variant& rhs)
5975 {
5976  return (rhs.m_type == unit_variant::Type::Type5) && (rhs.m_impl.m_value5 == lhs);
5977 }
5978 inline bool operator!=(const unit_variant& lhs, const ossia::color_u& rhs)
5979 {
5980  return (lhs.m_type != unit_variant::Type::Type5) || (lhs.m_impl.m_value5 != rhs);
5981 }
5982 inline bool operator!=(const ossia::color_u& lhs, const unit_variant& rhs)
5983 {
5984  return (rhs.m_type != unit_variant::Type::Type5) || (rhs.m_impl.m_value5 != lhs);
5985 }
5986 inline bool operator==(const unit_variant& lhs, const ossia::gain_u& rhs)
5987 {
5988  return (lhs.m_type == unit_variant::Type::Type6) && (lhs.m_impl.m_value6 == rhs);
5989 }
5990 inline bool operator==(const ossia::gain_u& lhs, const unit_variant& rhs)
5991 {
5992  return (rhs.m_type == unit_variant::Type::Type6) && (rhs.m_impl.m_value6 == lhs);
5993 }
5994 inline bool operator!=(const unit_variant& lhs, const ossia::gain_u& rhs)
5995 {
5996  return (lhs.m_type != unit_variant::Type::Type6) || (lhs.m_impl.m_value6 != rhs);
5997 }
5998 inline bool operator!=(const ossia::gain_u& lhs, const unit_variant& rhs)
5999 {
6000  return (rhs.m_type != unit_variant::Type::Type6) || (rhs.m_impl.m_value6 != lhs);
6001 }
6002 inline bool operator==(const unit_variant& lhs, const ossia::timing_u& rhs)
6003 {
6004  return (lhs.m_type == unit_variant::Type::Type7) && (lhs.m_impl.m_value7 == rhs);
6005 }
6006 inline bool operator==(const ossia::timing_u& lhs, const unit_variant& rhs)
6007 {
6008  return (rhs.m_type == unit_variant::Type::Type7) && (rhs.m_impl.m_value7 == lhs);
6009 }
6010 inline bool operator!=(const unit_variant& lhs, const ossia::timing_u& rhs)
6011 {
6012  return (lhs.m_type != unit_variant::Type::Type7) || (lhs.m_impl.m_value7 != rhs);
6013 }
6014 inline bool operator!=(const ossia::timing_u& lhs, const unit_variant& rhs)
6015 {
6016  return (rhs.m_type != unit_variant::Type::Type7) || (rhs.m_impl.m_value7 != lhs);
6017 }
constexpr OSSIA_INLINE auto max(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
max function tailored for values
Definition: math.hpp:96
val_type matching_type(const unit_t &u)
underlying_type Get the implementation type of an unit
Definition: dataspace_visitors.cpp:198