S
Samkit Jain
Compiler: gcc 4.6.1
Code:
struct data
{
constexpr data(int i) :i_(i) {}
int i_;
};
template <typename T, int Size>
constexpr void const* get_addr(T const (&elements)[Size]) { return
(void const*)elements; }
template <typename T>
constexpr void const* get_addr(T const& element) { return (void
const*)&element; }
int main()
{
constexpr data elements[] = { data(10) };
constexpr data ten(10);
static_assert(get_addr(elements) == get_addr(elements), "not equal
- 1"); // doesn't compile?
static_assert(elements == elements, "not equal - 2");
static_assert(get_addr(ten) == get_addr(ten), "not equal -
3"); // doesn't compile?
static_assert(&ten == &ten, "not equal - 4");
return 0;
}
Code:
struct data
{
constexpr data(int i) :i_(i) {}
int i_;
};
template <typename T, int Size>
constexpr void const* get_addr(T const (&elements)[Size]) { return
(void const*)elements; }
template <typename T>
constexpr void const* get_addr(T const& element) { return (void
const*)&element; }
int main()
{
constexpr data elements[] = { data(10) };
constexpr data ten(10);
static_assert(get_addr(elements) == get_addr(elements), "not equal
- 1"); // doesn't compile?
static_assert(elements == elements, "not equal - 2");
static_assert(get_addr(ten) == get_addr(ten), "not equal -
3"); // doesn't compile?
static_assert(&ten == &ten, "not equal - 4");
return 0;
}