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 | |
| 46 | def configure(conf): |
| 47 | conf.check_friend_typename() |