Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/type_traits/tools/specialisations.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.6 KB
Line 
1
2//  (C) Copyright John Maddock 2000.
3//  Use, modification and distribution are subject to the
4//  Boost Software License, Version 1.0. (See accompanying file
5//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7//
8// Simple program to output some template specialisations for the type_traits library.
9//
10
11#include <fstream>
12
13using namespace std;
14
15unsigned specializations = 30;
16
17int main()
18{
19   unsigned i, j;
20   ofstream os("specialisations");
21
22   //
23   // generate is_function tester prototypes:
24   for(i = 0; i <= specializations; ++i)
25   {
26      os << "template <class R";
27      for(j = 0; j < i; ++j)
28      {
29         os << ", class A" << j;
30      }
31      os << ">\n::boost::type_traits::yes_type is_function_tester(R (*)(";
32      if(i == 0)
33         os << "void";
34      else
35      {
36         for(j = 0; j < i; ++j)
37         {
38            if(j) os << ", ";
39            os << "A" << j;
40         }
41      }
42      os << "));" << endl;
43   }
44   os << endl << endl;
45   //
46   // generate is_function_helper partial specialisations:
47   //
48   for(i = 0; i < specializations; ++i)
49   {
50      os << "template <class R";
51      for(j = 0; j < i; ++j)
52      {
53         os << ", class A" << j;
54      }
55      os << ">\nstruct is_function_helper_base<R (*)(";
56      if(i == 0)
57         os << "void";
58      else
59      {
60         for(j = 0; j < i; ++j)
61         {
62            if(j) os << ", ";
63            os << "A" << j;
64         }
65      }
66      os << ")>{ BOOST_STATIC_CONSTANT(bool, value = true); };" << endl;
67   }
68   os << endl << endl;
69
70
71   //
72   // generate is_member_pointer_helper tester prototypes:
73   for(i = 0; i <= specializations; ++i)
74   {
75      os << "template <class R, class T";
76      for(j = 0; j < i; ++j)
77      {
78         os << ", class A" << j;
79      }
80      os << ">\n::boost::type_traits::yes_type is_member_pointer_helper(R (T::*)(";
81      if(i == 0)
82         os << "void";
83      else
84      {
85         for(j = 0; j < i; ++j)
86         {
87            if(j) os << ", ";
88            os << "A" << j;
89         }
90      }
91      os << "));" << endl;
92   }
93   os << endl << endl;
94   //
95   // generate is_member_pointer partial specialisations:
96   //
97   for(i = 0; i < specializations; ++i)
98   {
99      os << "template <class R, class T";
100      for(j = 0; j < i; ++j)
101      {
102         os << ", class A" << j;
103      }
104      os << ">\nstruct is_member_pointer<R (T::*)(";
105      if(i == 0)
106         os << "void";
107      else
108      {
109         for(j = 0; j < i; ++j)
110         {
111            if(j) os << ", ";
112            os << "A" << j;
113         }
114      }
115      os << ")>{ BOOST_STATIC_CONSTANT(bool, value = true); };" << endl;
116   }
117   os << endl << endl;
118
119
120   return 0;
121}
122
Note: See TracBrowser for help on using the repository browser.