Fix three minor memory leaks in the Editor by using Gtk::manage
[ardour.git] / libs / glibmm2 / scripts / cxx_std.m4
1 cv_cxx_has_namespace_std
2 ## GLIBMM_CXX_HAS_NAMESPACE_STD()
3 ##
4 ## Test whether libstdc++ declares namespace std.  For safety,
5 ## also check whether several randomly selected STL symbols
6 ## are available in namespace std.
7 ##
8 ## On success, #define GLIBMM_HAVE_NAMESPACE_STD to 1.
9 ##
10 AC_DEFUN([GLIBMM_CXX_HAS_NAMESPACE_STD],
11 [
12   AC_CACHE_CHECK(
13     [whether C++ library symbols are declared in namespace std],
14     [gtkmm_cv_cxx_has_namespace_std],
15   [
16     AC_TRY_COMPILE(
17     [
18       #include <algorithm>
19       #include <iterator>
20       #include <iostream>
21       #include <string>
22     ],[
23       using std::min;
24       using std::find;
25       using std::copy;
26       using std::bidirectional_iterator_tag;
27       using std::string;
28       using std::istream;
29       using std::cout;
30     ],
31       [gtkmm_cv_cxx_has_namespace_std="yes"],
32       [gtkmm_cv_cxx_has_namespace_std="no"]
33     )
34   ])
35
36   if test "x${gtkmm_cv_cxx_has_namespace_std}" = "xyes"; then
37   {
38     AC_DEFINE([GLIBMM_HAVE_NAMESPACE_STD],[1], [Defined when the libstdc++ declares the std-namespace])
39   }
40   fi
41 ])
42
43
44 ## GLIBMM_CXX_HAS_STD_ITERATOR_TRAITS()
45 ##
46 ## Check for standard-conform std::iterator_traits<>, and
47 ## #define GLIBMM_HAVE_STD_ITERATOR_TRAITS on success.
48 ##
49 AC_DEFUN([GLIBMM_CXX_HAS_STD_ITERATOR_TRAITS],
50 [
51   AC_REQUIRE([GLIBMM_CXX_HAS_NAMESPACE_STD])
52
53   AC_CACHE_CHECK(
54     [whether the C++ library supports std::iterator_traits],
55     [gtkmm_cv_cxx_has_std_iterator_traits],
56   [
57     AC_TRY_COMPILE(
58     [
59       #include <iterator>
60       #ifdef GLIBMM_HAVE_NAMESPACE_STD
61       using namespace std;
62       #endif
63     ],[
64       typedef iterator_traits<char*>::value_type ValueType;
65     ],
66       [gtkmm_cv_cxx_has_std_iterator_traits="yes"],
67       [gtkmm_cv_cxx_has_std_iterator_traits="no"]
68     )
69   ])
70
71   if test "x${gtkmm_cv_cxx_has_std_iterator_traits}" = "xyes"; then
72   {
73     AC_DEFINE([GLIBMM_HAVE_STD_ITERATOR_TRAITS],[1], [Defined if std::iterator_traits<> is standard-conforming])
74   }
75   fi
76 ])
77
78
79 ## GLIBMM_CXX_HAS_SUN_REVERSE_ITERATOR()
80 ##
81 ## Check for Sun libCstd style std::reverse_iterator,
82 ## and #define GLIBMM_HAVE_SUN_REVERSE_ITERATOR if found.
83 ##
84 AC_DEFUN([GLIBMM_CXX_HAS_SUN_REVERSE_ITERATOR],
85 [
86   AC_REQUIRE([GLIBMM_CXX_HAS_NAMESPACE_STD])
87
88   AC_CACHE_CHECK(
89     [for non-standard Sun libCstd reverse_iterator],
90     [gtkmm_cv_cxx_has_sun_reverse_iterator],
91   [
92     AC_TRY_COMPILE(
93     [
94       #include <iterator>
95       #ifdef GLIBMM_HAVE_NAMESPACE_STD
96       using namespace std;
97       #endif
98     ],[
99       typedef reverse_iterator<char*,random_access_iterator_tag,char,char&,char*,int> ReverseIter;
100     ],
101       [gtkmm_cv_cxx_has_sun_reverse_iterator="yes"],
102       [gtkmm_cv_cxx_has_sun_reverse_iterator="no"]
103     )
104   ])
105
106   if test "x${gtkmm_cv_cxx_has_sun_reverse_iterator}" = "xyes"; then
107   {
108     AC_DEFINE([GLIBMM_HAVE_SUN_REVERSE_ITERATOR],[1], [Defined if std::reverse_iterator is in Sun libCstd style])
109   }
110   fi
111 ])
112
113
114 ## GLIBMM_CXX_HAS_TEMPLATE_SEQUENCE_CTORS()
115 ##
116 ## Check whether the STL containers have templated sequence ctors,
117 ## and #define GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS on success.
118 ##
119 AC_DEFUN([GLIBMM_CXX_HAS_TEMPLATE_SEQUENCE_CTORS],
120 [
121   AC_REQUIRE([GLIBMM_CXX_HAS_NAMESPACE_STD])
122
123   AC_CACHE_CHECK(
124     [whether STL containers have templated sequence constructors],
125     [gtkmm_cv_cxx_has_template_sequence_ctors],
126   [
127     AC_TRY_COMPILE(
128     [
129       #include <vector>
130       #include <deque>
131       #include <list>
132       #ifdef GLIBMM_HAVE_NAMESPACE_STD
133       using namespace std;
134       #endif
135     ],[
136       const int array[8] = { 0, };
137       vector<int>  test_vector (&array[0], &array[8]);
138       deque<short> test_deque  (test_vector.begin(), test_vector.end());
139       list<long>   test_list   (test_deque.begin(),  test_deque.end());
140       test_vector.assign(test_list.begin(), test_list.end());
141     ],
142       [gtkmm_cv_cxx_has_template_sequence_ctors="yes"],
143       [gtkmm_cv_cxx_has_template_sequence_ctors="no"]
144     )
145   ])
146
147   if test "x${gtkmm_cv_cxx_has_template_sequence_ctors}" = "xyes"; then
148   {
149     AC_DEFINE([GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS],[1], [Defined if the STL containers have templated sequence ctors])
150   }
151   fi
152 ])
153
154 ## GLIBMM_CXX_ALLOWS_STATIC_INLINE_NPOS()
155 ##
156 ## Check whether the a static member variable may be initialized inline to std::string::npos.
157 ## The MipsPro (IRIX) compiler does not like this.
158 ## and #define GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS on success.
159 ##
160 AC_DEFUN([GLIBMM_CXX_ALLOWS_STATIC_INLINE_NPOS],
161 [
162   AC_REQUIRE([GLIBMM_CXX_HAS_NAMESPACE_STD])
163
164   AC_CACHE_CHECK(
165     [whether the compiler allows a static member variable to be initialized inline to std::string::npos],
166     [gtkmm_cv_cxx_has_allows_static_inline_npos],
167   [
168     AC_TRY_COMPILE(
169     [
170       #include <string>
171       #include <iostream>
172       
173       class ustringtest
174       {
175         public:
176         //The MipsPro compiler (IRIX) says "The indicated constant value is not known",
177         //so we need to initalize the static member data elsewhere.
178         static const std::string::size_type ustringnpos = std::string::npos;
179       };
180     ],[
181       std::cout << "npos=" << ustringtest::ustringnpos << std::endl;
182     ],
183       [gtkmm_cv_cxx_has_allows_static_inline_npos="yes"],
184       [gtkmm_cv_cxx_has_allows_static_inline_npos="no"]
185     )
186   ])
187
188   if test "x${gtkmm_cv_cxx_has_allows_static_inline_npos}" = "xyes"; then
189   {
190     AC_DEFINE([GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS],[1], [Defined if a static member variable may be initialized inline to std::string::npos])
191   }
192   fi
193 ])
194
195