Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
| 3 | from waflib.Configure import conf |
| 4 | |
| 5 | FRIEND_TYPENAME = ''' |
| 6 | class A; |
| 7 | |
| 8 | template<typename T> |
| 9 | class B |
| 10 | { |
| 11 | friend T; |
| 12 | }; |
| 13 | |
| 14 | B<A> g_b; |
| 15 | ''' |
| 16 | |
| 17 | FRIEND_WRAPPER = ''' |
| 18 | class A; |
| 19 | |
| 20 | template<typename T> |
| 21 | struct TypeWrapper |
| 22 | { |
| 23 | typedef T Type; |
| 24 | }; |
| 25 | |
| 26 | template<typename T> |
| 27 | class B |
| 28 | { |
| 29 | friend class TypeWrapper<T>::Type; |
| 30 | }; |
| 31 | |
| 32 | B<A> g_b; |
| 33 | ''' |
| 34 | |
| 35 | @conf |
| 36 | def 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 | |
Junxiao Shi | 895395f | 2015-03-03 22:38:56 -0700 | [diff] [blame] | 46 | OVERRIDE = ''' |
| 47 | class Base |
| 48 | { |
| 49 | virtual void |
| 50 | f(int a); |
| 51 | }; |
| 52 | |
| 53 | class Derived : public Base |
| 54 | { |
| 55 | virtual void |
| 56 | f(int a) override; |
| 57 | }; |
| 58 | |
| 59 | class Final : public Derived |
| 60 | { |
| 61 | virtual void |
| 62 | f(int a) final; |
| 63 | }; |
| 64 | ''' |
| 65 | |
| 66 | @conf |
| 67 | def check_override(self): |
| 68 | if self.check_cxx(msg='Checking for override and final specifiers', |
| 69 | fragment=OVERRIDE, |
| 70 | features='cxx', mandatory=False): |
| 71 | self.define('HAVE_CXX_OVERRIDE_FINAL', 1) |
| 72 | |
Davide Pesavento | 96b96af | 2015-09-19 23:00:40 +0200 | [diff] [blame] | 73 | STD_TO_STRING = ''' |
| 74 | #include <string> |
| 75 | int |
Davide Pesavento | 7c02b47 | 2015-10-28 20:50:17 +0100 | [diff] [blame] | 76 | main() |
Davide Pesavento | 96b96af | 2015-09-19 23:00:40 +0200 | [diff] [blame] | 77 | { |
| 78 | std::string s = std::to_string(0); |
| 79 | s = std::to_string(0l); |
| 80 | s = std::to_string(0ll); |
| 81 | s = std::to_string(0u); |
| 82 | s = std::to_string(0ul); |
| 83 | s = std::to_string(0ull); |
| 84 | s = std::to_string(0.0f); |
| 85 | s = std::to_string(0.0); |
| 86 | s = std::to_string(0.0l); |
| 87 | s.clear(); |
Davide Pesavento | 96b96af | 2015-09-19 23:00:40 +0200 | [diff] [blame] | 88 | } |
| 89 | ''' |
| 90 | |
| 91 | @conf |
| 92 | def check_std_to_string(self): |
| 93 | if self.check_cxx(msg='Checking for std::to_string', |
| 94 | fragment=STD_TO_STRING, |
| 95 | features='cxx', mandatory=False): |
| 96 | self.define('HAVE_STD_TO_STRING', 1) |
| 97 | |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 98 | VECTOR_INSERT_ERASE_CONST_ITERATOR = ''' |
| 99 | #include <vector> |
| 100 | int |
| 101 | main() |
| 102 | { |
| 103 | std::vector<int> v; |
| 104 | std::vector<int>::const_iterator it = v.cbegin(); |
| 105 | |
| 106 | v.insert(it, 2); |
| 107 | it = v.cend() - 1; |
| 108 | v.erase(it); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 109 | } |
| 110 | ''' |
| 111 | |
| 112 | @conf |
| 113 | def check_vector_const_iterators(self): |
Davide Pesavento | 96b96af | 2015-09-19 23:00:40 +0200 | [diff] [blame] | 114 | if self.check_cxx(msg='Checking for std::vector::insert with const_iterator', |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 115 | fragment=VECTOR_INSERT_ERASE_CONST_ITERATOR, |
| 116 | features='cxx', mandatory=False): |
Davide Pesavento | 96b96af | 2015-09-19 23:00:40 +0200 | [diff] [blame] | 117 | self.define('HAVE_VECTOR_INSERT_ERASE_CONST_ITERATOR', 1) |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 118 | |
Junxiao Shi | 8d71fdb | 2014-12-07 21:55:19 -0700 | [diff] [blame] | 119 | def configure(conf): |
| 120 | conf.check_friend_typename() |
Junxiao Shi | 895395f | 2015-03-03 22:38:56 -0700 | [diff] [blame] | 121 | conf.check_override() |
Davide Pesavento | 96b96af | 2015-09-19 23:00:40 +0200 | [diff] [blame] | 122 | conf.check_std_to_string() |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 123 | conf.check_vector_const_iterators() |