cprover
cpp_template_type.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@cs.cmu.edu
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_CPP_CPP_TEMPLATE_TYPE_H
11 #define CPROVER_CPP_CPP_TEMPLATE_TYPE_H
12 
13 #include <util/invariant.h>
14 #include <util/type.h>
15 
16 #include "cpp_template_parameter.h"
17 
18 class template_typet:public typet
19 {
20 public:
21  template_typet():typet(ID_template)
22  {
23  }
24 
25  typedef std::vector<template_parametert> template_parameterst;
26 
28  {
29  return (template_parameterst &)add(ID_template_parameters).get_sub();
30  }
31 
33  {
34  return (const template_parameterst &)find(ID_template_parameters).get_sub();
35  }
36 };
37 
39 {
40  PRECONDITION(type.id() == ID_template);
41  return static_cast<template_typet &>(type);
42 }
43 
44 inline const template_typet &to_template_type(const typet &type)
45 {
46  PRECONDITION(type.id() == ID_template);
47  return static_cast<const template_typet &>(type);
48 }
49 
50 inline const typet &template_subtype(const typet &type)
51 {
52  if(type.id()==ID_template)
53  return type.subtype();
54 
55  return type;
56 }
57 
59 {
60  if(type.id()==ID_template)
61  return type.subtype();
62 
63  return type;
64 }
65 
66 #endif // CPROVER_CPP_CPP_TEMPLATE_TYPE_H
The type of an expression, extends irept.
Definition: type.h:27
std::vector< template_parametert > template_parameterst
template_parameterst & template_parameters()
const typet & template_subtype(const typet &type)
subt & get_sub()
Definition: irep.h:317
const template_parameterst & template_parameters() const
const irep_idt & id() const
Definition: irep.h:259
#define PRECONDITION(CONDITION)
Definition: invariant.h:438
irept & add(const irep_namet &name)
Definition: irep.cpp:305
const typet & subtype() const
Definition: type.h:38
const irept & find(const irep_namet &name) const
Definition: irep.cpp:284
template_typet & to_template_type(typet &type)
Defines typet, type_with_subtypet and type_with_subtypest.