Sharing a trivial static_assert meta-function, any comments?

  • Thread starter christopher diggins
  • Start date
C

christopher diggins

I just wanted to share a static_assert meta-function, and see if anyone had
any comments. I was looking for a simpler alternative to the big old BOOST
one which is overkill for my purposes (see :
http://www.ootl.org/boost/static_assert.hpp.htm )

template<bool b>
struct static_assert {
};

template<>
struct static_assert<false> {
private:
static_assert();
};

int main() {
static_assert<true>();
static_assert<2 + 2 == 4>();
static_assert<2 + 2 == 3>();
return 0;
}

Any comments?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top