File: ite.h

package info (click to toggle)
symfpu 0.0~git20190517.8fbe139-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 448 kB
  • sloc: ansic: 2,280; cpp: 290; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,399 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
** Copyright (C) 2018 Martin Brain
**
** See the file LICENSE for licensing information.
*/

/*
** ite.h
**
** Martin Brain
** martin.brain@cs.ox.ac.uk
** 03/12/14
**
** The handling of if-then-else depends on the type of both the condition
** (i.e. is it concrete or is it symbolic) and the type of the data
** (i.e. is it a symbolic class that wraps a tree node, is it a structure 
** containing them, etc.).  Some of the handling will work for any condition,
** any of the data, etc.  So far not difficult in a language with multiple
** dispatch including type variables.
**
** However, we are using C++, so there are a few extra hoops to jump
** through.  We declare ITEs as a struct containing a static function
** as then we can partially specialise templates of them.
** Specialisations of these are then given when appropriate types are
** introduced.  Care must be taken with these to ensure that we don't
** get ambigious template instantiations.
**
*/

#ifndef SYMFPU_ITE
#define SYMFPU_ITE

namespace symfpu {

  template <class prop, class data>
    struct ite;

  // To avoid the need for putting the types *everywhere* we use a
  // helper function as C++ can perform type inference for functions
  // but not classes.
  template <class prop, class data>
    const data ITE (const prop &c, const data &l, const data &r) {
    return ite<prop, data>::iteOp(c, l, r);
  }

}

#endif