Skip to content

Instantly share code, notes, and snippets.

View Bueddl's full-sized avatar

Sebastian Büttner Bueddl

View GitHub Profile
void node_param_value(std::shared_ptr<tag_node> &node, const std::string &value)
{
auto string = std::make_shared<xmlrpc::tag_node>("string");
string->append_child(std::make_shared<xmlrpc::text_node>(value));
node->append_child(string);
}
void node_param_value(std::shared_ptr<tag_node> &node, int value)
@Bueddl
Bueddl / memfn_cast.cpp
Created January 8, 2017 00:15
cast class member functions to unsigned long (to obtain their addresses in code)
template<class T, class R, class... As>
constexpr unsigned long memfn_cast(R(T::*mfnp)(As...))
{
union {
unsigned long u_ul;
R(T::*u_mfnp)(As...);
} addr;
addr.u_mfnp = mfnp;
return addr.u_ul;
#include <iostream>
class my_class
{
public:
void test()
{
std::cout << "Hello C++" << std::endl;
}
class replacement
{
public:
void setter(int a)
{
_setter(this, a);
}
int getter() const
{
class replacement
{
public:
void **vmt;
void setter(int a)
{
_setter(this, a);
}
class replacement
{
public:
struct vmt_t
{
void (*dtor)(void* _this);
getter_fn_t *virtual_getter;
} *vmt;
void setter(int a)
class my_class
{
public:
virtual ~my_class()
{
std::cout << __PRETTY_FUNCTION__ << "() called" << std::endl;
}
void setter(int a)
{
#include <iostream>
class my_class
{
public:
void setter(int a)
{
_some_member = a;
}
@Bueddl
Bueddl / sys5_call.cpp
Created January 4, 2017 19:29
sys5 calling convention for member function ptr
#include <iostream>
class my_class
{
public:
void setter(int a)
{
_some_member = a;
}
@Bueddl
Bueddl / nullptr.cpp
Created November 1, 2016 15:48
save nullptr
class my_nullptr_t
{
public:
template<class T>
operator T*() const noexcept
{
return reinterpret_cast<T*>(0);
}
} my_nullptr;