CBMC
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  using typet::subtype;
38 };
39 
41 {
42  PRECONDITION(type.id() == ID_template);
43  return static_cast<template_typet &>(type);
44 }
45 
46 inline const template_typet &to_template_type(const typet &type)
47 {
48  PRECONDITION(type.id() == ID_template);
49  return static_cast<const template_typet &>(type);
50 }
51 
52 inline const typet &template_subtype(const typet &type)
53 {
54  if(type.id()==ID_template)
55  return to_type_with_subtype(type).subtype();
56 
57  return type;
58 }
59 
61 {
62  if(type.id()==ID_template)
63  return to_template_type(type).subtype();
64 
65  return type;
66 }
67 
68 #endif // CPROVER_CPP_CPP_TEMPLATE_TYPE_H
typet::subtype
const typet & subtype() const
Definition: type.h:50
typet
The type of an expression, extends irept.
Definition: type.h:28
irept::find
const irept & find(const irep_idt &name) const
Definition: irep.cpp:106
template_typet::subtype
const typet & subtype() const
Definition: type.h:50
invariant.h
to_type_with_subtype
const type_with_subtypet & to_type_with_subtype(const typet &type)
Definition: type.h:193
cpp_template_parameter.h
template_typet::template_typet
template_typet()
Definition: cpp_template_type.h:21
type.h
template_subtype
const typet & template_subtype(const typet &type)
Definition: cpp_template_type.h:52
template_typet::template_parameters
const template_parameterst & template_parameters() const
Definition: cpp_template_type.h:32
template_typet::template_parameters
template_parameterst & template_parameters()
Definition: cpp_template_type.h:27
PRECONDITION
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
template_typet::template_parameterst
std::vector< template_parametert > template_parameterst
Definition: cpp_template_type.h:25
irept::id
const irep_idt & id() const
Definition: irep.h:396
irept::add
irept & add(const irep_idt &name)
Definition: irep.cpp:116
irept::get_sub
subt & get_sub()
Definition: irep.h:456
type_with_subtypet::subtype
const typet & subtype() const
Definition: type.h:172
template_typet
Definition: cpp_template_type.h:18
to_template_type
template_typet & to_template_type(typet &type)
Definition: cpp_template_type.h:40