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
|
||||
|
||||
#include <iostream>
|
||||
#ifndef CHECK
|
||||
#define CHECK std::cout << __FILE__ << ": @" << __LINE__ << " in " << __func__ << std::endl;
|
||||
#endif
|
||||
#ifndef VCHECK
|
||||
#define VCHECK(a) std::cout << __FILE__ << ": @" << __LINE__ \
|
||||
<< " in " << __func__ << ": " << #a << " = " << a << std::endl;
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define CHECK
|
||||
|
|
|
@ -4,10 +4,15 @@
|
|||
|
||||
#include "base_def.h"
|
||||
#include "slice.h"
|
||||
#include <ostream>
|
||||
#include "pack_num.h"
|
||||
|
||||
namespace MultiArrayTools
|
||||
{
|
||||
|
||||
template <typename... T>
|
||||
std::ostream& operator<<(std::ostream& out, const std::tuple<T...>& tp);
|
||||
|
||||
template <class RangeType>
|
||||
auto getIndex(std::shared_ptr<RangeType> range)
|
||||
-> std::shared_ptr<typename RangeType::IndexType>;
|
||||
|
@ -27,6 +32,15 @@ namespace MultiArrayTools
|
|||
template <class... RangeTypes>
|
||||
auto mkMulti(std::tuple<std::shared_ptr<RangeTypes>...> rangesTuple)
|
||||
-> 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
|
||||
{
|
||||
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>
|
||||
auto getIndex(std::shared_ptr<RangeType> range)
|
||||
-> std::shared_ptr<typename RangeType::IndexType>
|
||||
|
@ -78,6 +99,20 @@ namespace MultiArrayTools
|
|||
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
|
||||
|
|
|
@ -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