fix check if COMMAND_RPC_GET_ALT_BLOCKS_HASHES exists added

master
moneroexamples 7 years ago
parent 68c3d97fd8
commit 160a1abe48

@ -11,37 +11,50 @@
#include <mutex> #include <mutex>
namespace namespace
{ {
// can be used to check if given class/struct exist // can be used to check if given class/struct exist
// from: https://stackoverflow.com/a/10722840/248823 // from: https://stackoverflow.com/a/10722840/248823
template <typename T> template <typename T>
struct has_destructor struct has_destructor
{
// has destructor
template <typename A>
static std::true_type test(decltype(declval<A>().~A()) *)
{ {
// has destructor return std::true_type();
template <typename A> }
static std::true_type test(decltype(declval<A>().~A()) *)
{
return std::true_type();
}
// no constructor // no constructor
template <typename A> template <typename A>
static std::false_type test(...) static std::false_type test(...)
{ {
return std::false_type(); return std::false_type();
} }
/* This will be either `std::true_type` or `std::false_type` */ /* This will be either `std::true_type` or `std::false_type` */
typedef decltype(test<T>(0)) type; typedef decltype(test<T>(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<string>& alt_blocks_hashes);
struct COMMAND_RPC_GET_ALT_BLOCKS_HASHES;
}
namespace xmreg namespace xmreg
{ {
@ -49,12 +62,7 @@ using namespace cryptonote;
using namespace crypto; using namespace crypto;
using namespace std; 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<string>& alt_blocks_hashes);
struct COMMAND_RPC_GET_ALT_BLOCKS_HASHES;
class rpccalls class rpccalls
{ {

Loading…
Cancel
Save