Commit 237edd05 authored by Anton Bukov's avatar Anton Bukov

Merge pull request #11 from babelvit/master

Linq Creators Improvement
parents 251feda7 a4972949
......@@ -753,20 +753,44 @@ namespace boolinq
return from<T>(array, array + N);
}
// std::list, vector, dequeue
template<template<class,class> class TV, typename TT, typename TU>
LinqObj<Enumerator<TT,IteratorContainerPair<typename TV<TT,TU>::const_iterator,TV<TT,TU> > > > from(TV<TT,TU> & container)
auto from(const TV<TT,TU> & container) -> LinqObj<Enumerator<TT,IteratorContainerPair<decltype(container.cbegin()),const TV<TT,TU> > > >
{
typedef IteratorContainerPair<typename TV<TT,TU>::const_iterator,TV<TT,TU> > DataType;
typedef IteratorContainerPair<decltype(container.cbegin()),const TV<TT,TU> > DataType;
return Enumerator<TT,DataType>([](DataType & pair){
return (pair.first == pair.second.cend()) ? throw EnumeratorEndException() : *(pair.first++);
}, DataType(container, [](const TV<TT,TU> & cont){return cont.cbegin();}));
}
template<template<class,int> class TV, typename TT, int TL>
LinqObj<Enumerator<TT,IteratorContainerPair<typename TV<TT,TL>::const_iterator,TV<TT,TL> > > > from(TV<TT,TL> & container)
// std::set
template<template<class,class,class> class TV, typename TT, typename TS, typename TU>
auto from(const TV<TT,TS,TU> & container) -> LinqObj<Enumerator<TT,IteratorContainerPair<decltype(container.cbegin()),const TV<TT,TS,TU> > > >
{
typedef IteratorContainerPair<typename TV<TT,TL>::const_iterator,TV<TT,TL> > DataType;
typedef IteratorContainerPair<decltype(container.cbegin()),const TV<TT,TS,TU> > DataType;
return Enumerator<TT,DataType>([](DataType & pair){
return (pair.first == pair.second.cend()) ? throw EnumeratorEndException() : *(pair.first++);
}, DataType(container, [](const TV<TT,TS,TU> & cont){return cont.cbegin();}));
}
// std::map
template<template<class,class,class,class> class TV, typename TK, typename TT, typename TS, typename TU>
auto from(const TV<TK,TT,TS,TU> & container) -> LinqObj<Enumerator<std::pair<TK,TT>,IteratorContainerPair<decltype(container.cbegin()),const TV<TK,TT,TS,TU> > > >
{
typedef IteratorContainerPair<decltype(container.cbegin()),const TV<TK,TT,TS,TU> > DataType;
return Enumerator<std::pair<TK,TT>,DataType>([](DataType & pair){
return (pair.first == pair.second.cend()) ? throw EnumeratorEndException() : *(pair.first++);
}, DataType(container, [](const TV<TK,TT,TS,TU> & cont){return cont.cbegin();}));
}
// std::array
template<template<class,unsigned> class TV, typename TT, unsigned TL>
auto from(const TV<TT,TL> & container) -> LinqObj<Enumerator<TT,IteratorContainerPair<decltype(container.cbegin()),const TV<TT,TL> > > >
{
typedef IteratorContainerPair<decltype(container.cbegin()),const TV<TT,TL> > DataType;
return Enumerator<TT,DataType>([](DataType & pair){
return (pair.first == pair.second.cend()) ? throw EnumeratorEndException() : *(pair.first++);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment