VL
Templates.h
Go to the documentation of this file.
1#pragma once
2
3template <typename TCollection, typename TValue>
5 MapReturnValue(typename TCollection::const_iterator it, bool valid)
6 : mIt(it)
7 , mValid(valid)
8 {}
9
10 inline const TValue& val() {
11 static const TValue emptyValue;
12 if (mValid)
13 return mIt->second;
14 else
15 return emptyValue;
16 }
17
18 inline operator bool() { return mValid; }
19
21 return { typename TCollection::const_iterator(), false }
22 }
23private:
24 bool mValid = false;
25 typename TCollection::const_iterator mIt;
26};
Definition: Templates.h:4
MapReturnValue(typename TCollection::const_iterator it, bool valid)
Definition: Templates.h:5
const TValue & val()
Definition: Templates.h:10
static MapReturnValue< TCollection, TValue > Null()
Definition: Templates.h:20