all_decl_seq.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // Copyright (C) 2009-2012 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0
  3. // (see accompanying file LICENSE_1_0.txt or a copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Home at http://www.boost.org/libs/local_function
  6. #include <boost/local_function.hpp>
  7. #include <boost/typeof/typeof.hpp>
  8. #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
  9. struct s;
  10. BOOST_TYPEOF_REGISTER_TYPE(s); // Register before bind `this_` below.
  11. // Compile all local function declaration combinations.
  12. struct s {
  13. void f(double p = 1.23, double q = -1.23) {
  14. { // Only params.
  15. void BOOST_LOCAL_FUNCTION( (int x) (int y)(default 0) ) {
  16. } BOOST_LOCAL_FUNCTION_NAME(l)
  17. l(1);
  18. }
  19. { // Only const binds.
  20. int a, b;
  21. const int& BOOST_LOCAL_FUNCTION( (const bind a)
  22. (const bind& b) (const bind& p) (const bind q) ) {
  23. return b;
  24. } BOOST_LOCAL_FUNCTION_NAME(l)
  25. l();
  26. const s& BOOST_LOCAL_FUNCTION( (const bind this_) ) {
  27. return *this_;
  28. } BOOST_LOCAL_FUNCTION_NAME(t)
  29. t();
  30. const int BOOST_LOCAL_FUNCTION( (const bind a)
  31. (const bind& b) (const bind& p) (const bind q)
  32. (const bind this_) ) {
  33. return a;
  34. } BOOST_LOCAL_FUNCTION_NAME(lt)
  35. lt();
  36. }
  37. { // Only plain binds.
  38. int c, d;
  39. int& BOOST_LOCAL_FUNCTION( (bind c) (bind& d)
  40. (bind& p) (bind& q) ) {
  41. return d;
  42. } BOOST_LOCAL_FUNCTION_NAME(l)
  43. l();
  44. s& BOOST_LOCAL_FUNCTION( (bind this_) ) {
  45. return *this_;
  46. } BOOST_LOCAL_FUNCTION_NAME(t)
  47. t();
  48. int BOOST_LOCAL_FUNCTION( (bind c) (bind& d)
  49. (bind& p) (bind& q) (bind this_) ) {
  50. return c;
  51. } BOOST_LOCAL_FUNCTION_NAME(lt)
  52. lt();
  53. }
  54. { // Both params and const binds.
  55. int a, b;
  56. void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
  57. (const bind& p) (const bind q)
  58. (int x) (int y)(default 0) ) {
  59. } BOOST_LOCAL_FUNCTION_NAME(l)
  60. l(1);
  61. void BOOST_LOCAL_FUNCTION( (const bind this_)
  62. (int x) (int y)(default 0) ) {
  63. } BOOST_LOCAL_FUNCTION_NAME(t)
  64. t(1);
  65. void BOOST_LOCAL_FUNCTION( (const bind a) (const bind this_)
  66. (const bind& b) (const bind& p) (const bind q)
  67. (int x) (int y)(default 0) ) {
  68. } BOOST_LOCAL_FUNCTION_NAME(lt)
  69. lt(1);
  70. }
  71. { // Both params and plain binds.
  72. int c, d;
  73. void BOOST_LOCAL_FUNCTION( (bind c) (bind& d) (bind& p) (bind q)
  74. (int x) (int y)(default 0) ) {
  75. } BOOST_LOCAL_FUNCTION_NAME(l)
  76. l(1);
  77. void BOOST_LOCAL_FUNCTION( (bind this_)
  78. (int x) (int y)(default 0) ) {
  79. } BOOST_LOCAL_FUNCTION_NAME(t)
  80. t(1);
  81. void BOOST_LOCAL_FUNCTION( (bind c) (bind& d)
  82. (bind& p) (bind this_) (bind q)
  83. (int x) (int y)(default 0) ) {
  84. } BOOST_LOCAL_FUNCTION_NAME(lt)
  85. lt(1);
  86. }
  87. { // Both const and plain binds.
  88. int a, b, c, d;
  89. void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
  90. (const bind p) (bind c) (bind& d) (bind q) ) {
  91. } BOOST_LOCAL_FUNCTION_NAME(l)
  92. l();
  93. void BOOST_LOCAL_FUNCTION( (const bind this_)
  94. (bind c) (bind& d) (bind q) ) {
  95. } BOOST_LOCAL_FUNCTION_NAME(ct)
  96. ct();
  97. void BOOST_LOCAL_FUNCTION( (const bind this_)
  98. (const bind a) (const bind& b) (const bind p)
  99. (bind c) (bind& d) (bind q) ) {
  100. } BOOST_LOCAL_FUNCTION_NAME(lct)
  101. lct();
  102. void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
  103. (const bind p) (bind this_) ) {
  104. } BOOST_LOCAL_FUNCTION_NAME(pt)
  105. pt();
  106. void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
  107. (const bind p) (bind c) (bind this_) (bind& d) (bind q) ) {
  108. } BOOST_LOCAL_FUNCTION_NAME(lpt)
  109. lpt();
  110. }
  111. { // All params, const binds, and plain binds.
  112. int a, b, c, d;
  113. void BOOST_LOCAL_FUNCTION(
  114. (const bind a) (const bind& b) (const bind& p)
  115. (bind c) (bind& d) (bind& q) (int x) (int y)(default 0) ) {
  116. } BOOST_LOCAL_FUNCTION_NAME(l)
  117. l(1);
  118. void BOOST_LOCAL_FUNCTION( (const bind this_)
  119. (bind c) (bind& d) (bind& q)
  120. (int x) (int y)(default 0) ) {
  121. } BOOST_LOCAL_FUNCTION_NAME(ct)
  122. ct(1);
  123. void BOOST_LOCAL_FUNCTION(
  124. (const bind a) (const bind& b) (const bind& p)
  125. (bind this_) (int x) (int y)(default 0) ) {
  126. } BOOST_LOCAL_FUNCTION_NAME(pt)
  127. pt(1);
  128. void BOOST_LOCAL_FUNCTION( (const bind a) (const bind this_)
  129. (const bind& b) (const bind& p) (bind c) (bind& d)
  130. (bind& q) (int x) (int y)(default 0) ) {
  131. } BOOST_LOCAL_FUNCTION_NAME(lct)
  132. lct(1);
  133. void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
  134. (const bind& p) (bind c) (bind& d) (bind this_) (bind& q)
  135. (int x) (int y)(default 0) ) {
  136. } BOOST_LOCAL_FUNCTION_NAME(lpt)
  137. lpt(1);
  138. }
  139. }
  140. };
  141. int main(void) {
  142. s().f();
  143. return 0;
  144. }