| 
									
										
										
										
											2009-02-25 18:04:27 +00:00
										 |  |  | //  (C) Copyright Beman Dawes 2008 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  Use, modification and distribution are subject to the | 
					
						
							|  |  |  | //  Boost Software License, Version 1.0. (See accompanying file | 
					
						
							|  |  |  | //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //  See http://www.boost.org/libs/config for more information. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-10 13:57:24 +00:00
										 |  |  | //  MACRO:         BOOST_NO_CXX11_CONSTEXPR  | 
					
						
							| 
									
										
										
										
											2009-02-25 18:04:27 +00:00
										 |  |  | //  TITLE:         C++0x constexpr unavailable | 
					
						
							|  |  |  | //  DESCRIPTION:   The compiler does not support C++0x constexpr | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-10 19:10:08 +00:00
										 |  |  | namespace boost_no_cxx11_constexpr { | 
					
						
							| 
									
										
										
										
											2009-02-25 18:04:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-31 11:21:10 +00:00
										 |  |  | void quiet_warning(int){} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-25 18:04:27 +00:00
										 |  |  | constexpr int square(int x) { return x * x; }  // from N2235 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-15 13:17:46 +00:00
										 |  |  | // from 5.19: | 
					
						
							|  |  |  | constexpr const int* addr(const int& ir) { return &ir; } | 
					
						
							|  |  |  | static const int x = 5; | 
					
						
							|  |  |  | constexpr const int* xp = addr(x); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct A  | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    constexpr A(int i) : val(i) { } | 
					
						
							| 
									
										
										
										
											2013-12-13 19:13:48 +00:00
										 |  |  |    constexpr operator int()const { return val; } | 
					
						
							|  |  |  |    constexpr operator long()const { return 43; } | 
					
						
							| 
									
										
										
										
											2011-03-15 13:17:46 +00:00
										 |  |  | private: | 
					
						
							|  |  |  |    int val; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<int> struct X { }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-13 19:13:48 +00:00
										 |  |  | constexpr const A a = 42; | 
					
						
							| 
									
										
										
										
											2011-03-15 13:17:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-30 18:24:18 +00:00
										 |  |  | X<a> xx; // OK: unique conversion to int | 
					
						
							| 
									
										
										
										
											2011-03-15 13:17:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-05 11:46:28 +02:00
										 |  |  | // virtual function | 
					
						
							|  |  |  | struct B | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    virtual void vf() {} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | struct C : B | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    constexpr C() {} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // aggregate initialization | 
					
						
							|  |  |  | struct D | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |    int val[2]; | 
					
						
							|  |  |  |    constexpr D() : val() {} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // virtual base | 
					
						
							|  |  |  | struct E | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | struct F : virtual E | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | constexpr F& f(F& out) { return out; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-25 18:04:27 +00:00
										 |  |  | int test() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int i = square(5); | 
					
						
							| 
									
										
										
										
											2011-10-31 11:21:10 +00:00
										 |  |  |   quiet_warning(i); | 
					
						
							| 
									
										
										
										
											2015-06-27 13:08:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   switch (i) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |   case a: | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-25 18:04:27 +00:00
										 |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |