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