[ create a new paste ] login | about

Link: http://codepad.org/lu0FnPv3    [ raw code | output | fork ]

C++, pasted on Jul 8:
#include <algorithm>
#include <iostream>
#include <iterator>

struct Foo {
  bool vin;
  bool bar[3];
  bool baz[3];
};

template<typename T, std::size_t N>
std::size_t array_size(T(&)[N]) { return N; }

std::ostream &operator<<(std::ostream &out, Foo const &f) {
  std::cout << f.vin << '\t';
  std::copy(f.bar, f.bar + array_size(f.bar), std::ostream_iterator<bool>(out, "\t"));
  std::copy(f.baz, f.baz + array_size(f.baz), std::ostream_iterator<bool>(out, "\t"));
  return out;
}

int main() {
  Foo baz = {true, true, false, true};
  Foo zoo = {false, {true, false}, { true }};

  std::cout << baz << '\n' << zoo << '\n';
}


Output:
1
2
3
cc1plus: warnings being treated as errors
In function 'int main()':
Line 22: warning: missing braces around initializer for 'bool [3]'


Create a new paste based on this one


Comments: