boost_no_priv_aggregate.ipp 856 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // (C) Copyright John Maddock 2001.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/config for most recent version.
  6. // MACRO: BOOST_NO_PRIVATE_IN_AGGREGATE
  7. // TITLE: private in aggregate types
  8. // DESCRIPTION: The compiler misreads 8.5.1, treating classes
  9. // as non-aggregate if they contain private or
  10. // protected member functions.
  11. namespace boost_no_private_in_aggregate{
  12. struct t
  13. {
  14. private:
  15. void foo(){ i = j; }
  16. public:
  17. void uncallable(); // silences warning from GCC
  18. int i;
  19. int j;
  20. };
  21. int test()
  22. {
  23. t inst = { 0, 0, };
  24. (void) &inst; // avoid "unused variable" warning
  25. return 0;
  26. }
  27. }