From 160a1abe489bb5442cb36f9bc793fc16fe38b47e Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Tue, 20 Jun 2017 14:21:56 +0800 Subject: [PATCH] fix check if COMMAND_RPC_GET_ALT_BLOCKS_HASHES exists added --- src/rpccalls.h | 60 ++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/src/rpccalls.h b/src/rpccalls.h index 596dc38..512bbe5 100644 --- a/src/rpccalls.h +++ b/src/rpccalls.h @@ -11,37 +11,50 @@ #include + + namespace { - // can be used to check if given class/struct exist - // from: https://stackoverflow.com/a/10722840/248823 - template - struct has_destructor +// can be used to check if given class/struct exist +// from: https://stackoverflow.com/a/10722840/248823 +template +struct has_destructor +{ + // has destructor + template + static std::true_type test(decltype(declval().~A()) *) { - // has destructor - template - static std::true_type test(decltype(declval().~A()) *) - { - return std::true_type(); - } + return std::true_type(); + } - // no constructor - template - static std::false_type test(...) - { - return std::false_type(); - } + // no constructor + template + static std::false_type test(...) + { + return std::false_type(); + } - /* This will be either `std::true_type` or `std::false_type` */ - typedef decltype(test(0)) type; + /* This will be either `std::true_type` or `std::false_type` */ + typedef decltype(test(0)) type; - static const bool value = type::value; - }; + static const bool value = type::value; +}; } +namespace cryptonote +{ +// declare struct in monero's cryptonote namespace. +// monero should provide definition for this, +// but we need to have it declared as we are going to +// check if its definition exist or not. depending on this +// we decide what gets to be defined as +// get_alt_blocks(vector& alt_blocks_hashes); +struct COMMAND_RPC_GET_ALT_BLOCKS_HASHES; +} + namespace xmreg { @@ -49,12 +62,7 @@ using namespace cryptonote; using namespace crypto; using namespace std; -// declare it. monero should provide definition for this, -// but we need to have it declared as we are going to -// check if its definition exist or not. depending on this -// we decide what gets to be defined as -// get_alt_blocks(vector& alt_blocks_hashes); -struct COMMAND_RPC_GET_ALT_BLOCKS_HASHES; + class rpccalls {