Fix arcana that made MSVC / GCC sad

GCC doesn't like specializations of inner classes declared inline, or 
using a shorthand type alias for static template member variable 
initialisation. 

MSVC doesn't like using a private type alias
nix
Owen Green 5 years ago
parent aba2795644
commit 3e31a4dcb4

@ -10,27 +10,34 @@ template <typename Client> class FluidSCWrapper;
namespace impl { namespace impl {
template <typename Client,typename Wrapper> template<bool UseRealTime> struct ChooseRTOrNRT;
struct BaseChooser
template<>
struct ChooseRTOrNRT<false>
{ {
template<bool>struct Choose template<typename Client, typename Wrapper>
{
using type = NonRealTime<Client,Wrapper>; using type = NonRealTime<Client,Wrapper>;
}; };
template<> template<>
struct Choose<true> struct ChooseRTOrNRT<true>
{ {
template<typename Client, typename Wrapper>
using type = RealTime<Client,Wrapper>; using type = RealTime<Client,Wrapper>;
}; };
template <typename Client,typename Wrapper>
struct BaseChooser
{
using RT = typename Client::isRealTime; using RT = typename Client::isRealTime;
static constexpr bool UseRealTime = RT::value && !IsModel_t<Client>::value; static constexpr bool UseRealTime = RT::value && !IsModel_t<Client>::value;
using type = typename Choose<UseRealTime>::type; using type = typename ChooseRTOrNRT<UseRealTime>::template type<Client,Wrapper>;
}; };
template <typename Client,typename Wrapper> template <typename Client,typename Wrapper>
using BaseChooser_t = typename BaseChooser<Client,Wrapper>::type; using BaseChooser_t = typename BaseChooser<Client,Wrapper>::type;

@ -44,13 +44,16 @@ namespace impl {
using CacheEntryPointer = std::shared_ptr<CacheEntry>; using CacheEntryPointer = std::shared_ptr<CacheEntry>;
using WeakCacheEntryPointer = std::weak_ptr<CacheEntry>; //could use weak_type in 17 using WeakCacheEntryPointer = std::weak_ptr<CacheEntry>; //could use weak_type in 17
using Cache = std::map<index,CacheEntryPointer>;
public:
using Cache = std::map<index,CacheEntryPointer>;
static Cache mCache;
private:
static bool isNull(WeakCacheEntryPointer const& weak) { static bool isNull(WeakCacheEntryPointer const& weak) {
return !weak.owner_before(WeakCacheEntryPointer{}) && !WeakCacheEntryPointer{}.owner_before(weak); return !weak.owner_before(WeakCacheEntryPointer{}) && !WeakCacheEntryPointer{}.owner_before(weak);
} }
static Cache mCache;
public: public:
static WeakCacheEntryPointer get(index id) static WeakCacheEntryPointer get(index id)
@ -201,10 +204,7 @@ namespace impl {
{ {
using NRTCommand::NRTCommand; using NRTCommand::NRTCommand;
void cancelCheck(std::false_type, index id)
template<bool b>
struct CancelCheck{
void operator()(index id)
{ {
if(auto ptr = get(id).lock()) if(auto ptr = get(id).lock())
{ {
@ -215,13 +215,9 @@ namespace impl {
<< std::endl; << std::endl;
} }
} }
};
template<> void cancelCheck(std::true_type, index){}
struct CancelCheck<true>{
void operator()(index)
{}
};
static const char* name() static const char* name()
{ {
@ -231,7 +227,7 @@ namespace impl {
bool stage2(World*) bool stage2(World*)
{ {
CancelCheck<IsRTQueryModel>()(NRTCommand::mID); cancelCheck(IsRTQueryModel_t(),NRTCommand::mID);
remove(NRTCommand::mID); remove(NRTCommand::mID);
NRTCommand::sendReply(name(), true); NRTCommand::sendReply(name(), true);
return true; return true;
@ -759,7 +755,7 @@ namespace impl {
if(auto ptr = get(mID).lock()) if(auto ptr = get(mID).lock())
{ {
bool trigger = (mPreviousTrigger <= 0) && mTrigger > 0; bool trigger = (!mPreviousTrigger) && mTrigger;
mPreviousTrigger = mTrigger; mPreviousTrigger = mTrigger;
mTrigger = 0; mTrigger = 0;
auto& client = ptr->mClient; auto& client = ptr->mClient;
@ -784,8 +780,8 @@ namespace impl {
} }
private: private:
bool mPreviousTrigger{0}; bool mPreviousTrigger{false};
bool mTrigger{0}; bool mTrigger{false};
Result mResult; Result mResult;
impl::FloatControlsIter mControlsIterator; impl::FloatControlsIter mControlsIterator;
index mID; index mID;
@ -948,18 +944,12 @@ namespace impl {
index checkThreadInterval; index checkThreadInterval;
index pollCounter{0}; index pollCounter{0};
index mPreviousTrigger{0}; index mPreviousTrigger{0};
bool mSynchronous{true}; bool mSynchronous{true};
Wrapper* mWrapper{static_cast<Wrapper*>(this)};
Result mResult; Result mResult;
}; };
//initialize static cache
template<typename Client, typename Wrapper>
using Cache = typename NonRealTime<Client,Wrapper>::Cache;
template<typename Client, typename Wrapper> template<typename Client, typename Wrapper>
Cache<Client,Wrapper> NonRealTime<Client,Wrapper>::mCache{}; typename NonRealTime<Client, Wrapper>::Cache NonRealTime<Client,Wrapper>::mCache{};
} }
} }

Loading…
Cancel
Save