blob: 39516e69ab391e4ec0e3453f0bb4bc6a7bc31f2b [file] [log] [blame]
Junxiao Shi8d71fdb2014-12-07 21:55:19 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
3from waflib.Configure import conf
4
5FRIEND_TYPENAME = '''
6class A;
7
8template<typename T>
9class B
10{
11 friend T;
12};
13
14B<A> g_b;
15'''
16
17FRIEND_WRAPPER = '''
18class A;
19
20template<typename T>
21struct TypeWrapper
22{
23 typedef T Type;
24};
25
26template<typename T>
27class B
28{
29 friend class TypeWrapper<T>::Type;
30};
31
32B<A> g_b;
33'''
34
35@conf
36def check_friend_typename(self):
37 if self.check_cxx(msg='Checking for friend typename-specifier',
38 fragment=FRIEND_TYPENAME,
39 features='cxx', mandatory=False):
40 self.define('HAVE_CXX_FRIEND_TYPENAME', 1)
41 elif self.check_cxx(msg='Checking for friend typename using wrapper',
42 fragment=FRIEND_WRAPPER,
43 features='cxx', mandatory=True):
44 self.define('HAVE_CXX_FRIEND_TYPENAME_WRAPPER', 1)
45
Davide Pesavento96b96af2015-09-19 23:00:40 +020046STD_TO_STRING = '''
47#include <string>
48int
Davide Pesavento7c02b472015-10-28 20:50:17 +010049main()
Davide Pesavento96b96af2015-09-19 23:00:40 +020050{
51 std::string s = std::to_string(0);
52 s = std::to_string(0l);
53 s = std::to_string(0ll);
54 s = std::to_string(0u);
55 s = std::to_string(0ul);
56 s = std::to_string(0ull);
57 s = std::to_string(0.0f);
58 s = std::to_string(0.0);
59 s = std::to_string(0.0l);
60 s.clear();
Davide Pesavento96b96af2015-09-19 23:00:40 +020061}
62'''
63
64@conf
65def check_std_to_string(self):
66 if self.check_cxx(msg='Checking for std::to_string',
67 fragment=STD_TO_STRING,
68 features='cxx', mandatory=False):
69 self.define('HAVE_STD_TO_STRING', 1)
70
Joao Pereira7476ebf2015-07-07 14:54:39 -040071VECTOR_INSERT_ERASE_CONST_ITERATOR = '''
72#include <vector>
73int
74main()
75{
76 std::vector<int> v;
77 std::vector<int>::const_iterator it = v.cbegin();
78
79 v.insert(it, 2);
80 it = v.cend() - 1;
81 v.erase(it);
Joao Pereira7476ebf2015-07-07 14:54:39 -040082}
83'''
84
85@conf
86def check_vector_const_iterators(self):
Davide Pesavento96b96af2015-09-19 23:00:40 +020087 if self.check_cxx(msg='Checking for std::vector::insert with const_iterator',
Joao Pereira7476ebf2015-07-07 14:54:39 -040088 fragment=VECTOR_INSERT_ERASE_CONST_ITERATOR,
89 features='cxx', mandatory=False):
Davide Pesavento96b96af2015-09-19 23:00:40 +020090 self.define('HAVE_VECTOR_INSERT_ERASE_CONST_ITERATOR', 1)
Joao Pereira7476ebf2015-07-07 14:54:39 -040091
Junxiao Shi8d71fdb2014-12-07 21:55:19 -070092def configure(conf):
93 conf.check_friend_typename()
Davide Pesavento96b96af2015-09-19 23:00:40 +020094 conf.check_std_to_string()
Joao Pereira7476ebf2015-07-07 14:54:39 -040095 conf.check_vector_const_iterators()