Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@g-pechorin
Last active November 13, 2015 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g-pechorin/d5eb8a1a770f783943a0 to your computer and use it in GitHub Desktop.
Save g-pechorin/d5eb8a1a770f783943a0 to your computer and use it in GitHub Desktop.
swag
#include "gtest/gtest.h"
/// alwasy test this to verify that the compiler will putup with my eccentricities
TEST(swag, basic)
{
struct swagged
{
size_t loarge(void) const
{
return reinterpret_cast<size_t>(this);
}
static const swagged* of(const size_t s)
{
return reinterpret_cast<const swagged*>(s);
}
size_t mul(size_t t) const
{
return loarge() * t;
}
private:
char _unused_but_GCC_needs_me____maybe___well_GCC_adds_ints_to_empty_classes_so_i_put_this_here;
swagged(void) = delete;
swagged(const swagged&) = delete;
swagged& operator=(const swagged&) = delete;
};
const swagged* s = swagged::of(7);
EXPECT_EQ(7, s->loarge());
EXPECT_EQ(14, s->mul(2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment