some utilities (move all to helper_tools.h)
This commit is contained in:
parent
edab24b63a
commit
a5292ef2ab
3 changed files with 39 additions and 30 deletions
|
@ -10,9 +10,13 @@
|
||||||
#ifdef DEBUG_MODE_X
|
#ifdef DEBUG_MODE_X
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#ifndef CHECK
|
||||||
#define CHECK std::cout << __FILE__ << ": @" << __LINE__ << " in " << __func__ << std::endl;
|
#define CHECK std::cout << __FILE__ << ": @" << __LINE__ << " in " << __func__ << std::endl;
|
||||||
|
#endif
|
||||||
|
#ifndef VCHECK
|
||||||
#define VCHECK(a) std::cout << __FILE__ << ": @" << __LINE__ \
|
#define VCHECK(a) std::cout << __FILE__ << ": @" << __LINE__ \
|
||||||
<< " in " << __func__ << ": " << #a << " = " << a << std::endl;
|
<< " in " << __func__ << ": " << #a << " = " << a << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define CHECK
|
#define CHECK
|
||||||
|
|
|
@ -4,9 +4,14 @@
|
||||||
|
|
||||||
#include "base_def.h"
|
#include "base_def.h"
|
||||||
#include "slice.h"
|
#include "slice.h"
|
||||||
|
#include <ostream>
|
||||||
|
#include "pack_num.h"
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template <typename... T>
|
||||||
|
std::ostream& operator<<(std::ostream& out, const std::tuple<T...>& tp);
|
||||||
|
|
||||||
template <class RangeType>
|
template <class RangeType>
|
||||||
auto getIndex(std::shared_ptr<RangeType> range)
|
auto getIndex(std::shared_ptr<RangeType> range)
|
||||||
|
@ -27,6 +32,15 @@ namespace MultiArrayTools
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
auto mkMulti(std::tuple<std::shared_ptr<RangeTypes>...> rangesTuple)
|
auto mkMulti(std::tuple<std::shared_ptr<RangeTypes>...> rangesTuple)
|
||||||
-> MultiRange<RangeTypes...>;
|
-> MultiRange<RangeTypes...>;
|
||||||
|
|
||||||
|
template <class RangeFactory>
|
||||||
|
auto createExplicit(RangeFactory& rf)
|
||||||
|
-> std::shared_ptr<typename RangeFactory::oType>;
|
||||||
|
|
||||||
|
template <class RangeFactory>
|
||||||
|
auto createExplicit(std::shared_ptr<RangeFactory> rfp)
|
||||||
|
-> std::shared_ptr<typename RangeFactory::oType>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================= *
|
/* ========================= *
|
||||||
|
@ -35,6 +49,13 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
template <typename... T>
|
||||||
|
std::ostream& operator<<(std::ostream& out, const std::tuple<T...>& tp)
|
||||||
|
{
|
||||||
|
PackNum<sizeof...(T)-1>::printTuple(out, tp);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
template <class RangeType>
|
template <class RangeType>
|
||||||
auto getIndex(std::shared_ptr<RangeType> range)
|
auto getIndex(std::shared_ptr<RangeType> range)
|
||||||
-> std::shared_ptr<typename RangeType::IndexType>
|
-> std::shared_ptr<typename RangeType::IndexType>
|
||||||
|
@ -78,6 +99,20 @@ namespace MultiArrayTools
|
||||||
return std::dynamic_pointer_cast<MultiRange<RangeTypes...> >( mrf.create() );
|
return std::dynamic_pointer_cast<MultiRange<RangeTypes...> >( mrf.create() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class RangeFactory>
|
||||||
|
auto createExplicit(RangeFactory& rf)
|
||||||
|
-> std::shared_ptr<typename RangeFactory::oType>
|
||||||
|
{
|
||||||
|
return std::dynamic_pointer_cast<typename RangeFactory::oType>( rf.create() );
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class RangeFactory>
|
||||||
|
auto createExplicit(std::shared_ptr<RangeFactory> rfp)
|
||||||
|
-> std::shared_ptr<typename RangeFactory::oType>
|
||||||
|
{
|
||||||
|
return std::dynamic_pointer_cast<typename RangeFactory::oType>( rfp->create() );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
|
|
||||||
#ifndef __utils_h__
|
|
||||||
#define __utils_h__
|
|
||||||
|
|
||||||
#include <ostream>
|
|
||||||
#include "pack_num.h"
|
|
||||||
|
|
||||||
namespace MultiArrayHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
using namespace MultiArrayTools;
|
|
||||||
|
|
||||||
template <typename... T>
|
|
||||||
std::ostream& operator<<(std::ostream& out, const std::tuple<T...>& tp);
|
|
||||||
|
|
||||||
/*==================*
|
|
||||||
* TEMPLATE CODE *
|
|
||||||
*==================*/
|
|
||||||
|
|
||||||
template <typename... T>
|
|
||||||
std::ostream& operator<<(std::ostream& out, const std::tuple<T...>& tp)
|
|
||||||
{
|
|
||||||
PackNum<sizeof...(T)-1>::printTuple(out, tp);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace MultiArrayHelper
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue