Added text of MIT License.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1115 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
199f8bcade
commit
d2ca522cca
43 changed files with 1541 additions and 1021 deletions
|
@ -4,13 +4,26 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_ABSTRACTFACTORY_INC_
|
||||
#define LOKI_ABSTRACTFACTORY_INC_
|
||||
|
|
|
@ -2,13 +2,23 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2008 by Rich Sposato
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LOKI_ALLOCATOR_HPP_INCLUDED
|
||||
|
|
|
@ -2,15 +2,26 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_ASSOCVECTOR_INC_
|
||||
#define LOKI_ASSOCVECTOR_INC_
|
||||
|
@ -42,21 +53,21 @@ namespace Loki
|
|||
public:
|
||||
AssocVectorCompare()
|
||||
{}
|
||||
|
||||
|
||||
AssocVectorCompare(const C& src) : C(src)
|
||||
{}
|
||||
|
||||
bool operator()(const first_argument_type& lhs,
|
||||
|
||||
bool operator()(const first_argument_type& lhs,
|
||||
const first_argument_type& rhs) const
|
||||
{ return C::operator()(lhs, rhs); }
|
||||
|
||||
|
||||
bool operator()(const Data& lhs, const Data& rhs) const
|
||||
{ return operator()(lhs.first, rhs.first); }
|
||||
|
||||
bool operator()(const Data& lhs,
|
||||
|
||||
bool operator()(const Data& lhs,
|
||||
const first_argument_type& rhs) const
|
||||
{ return operator()(lhs.first, rhs); }
|
||||
|
||||
|
||||
bool operator()(const first_argument_type& lhs,
|
||||
const Data& rhs) const
|
||||
{ return operator()(lhs, rhs.first); }
|
||||
|
@ -82,7 +93,7 @@ namespace Loki
|
|||
class C = std::less<K>,
|
||||
class A = std::allocator< std::pair<K, V> >
|
||||
>
|
||||
class AssocVector
|
||||
class AssocVector
|
||||
: private std::vector< std::pair<K, V>, A >
|
||||
, private Private::AssocVectorCompare<V, C>
|
||||
{
|
||||
|
@ -112,7 +123,7 @@ namespace Loki
|
|||
, private key_compare
|
||||
{
|
||||
friend class AssocVector;
|
||||
|
||||
|
||||
protected:
|
||||
value_compare(key_compare pred) : key_compare(pred)
|
||||
{}
|
||||
|
@ -121,27 +132,27 @@ namespace Loki
|
|||
bool operator()(const value_type& lhs, const value_type& rhs) const
|
||||
{ return key_compare::operator()(lhs.first, rhs.first); }
|
||||
};
|
||||
|
||||
|
||||
// 23.3.1.1 construct/copy/destroy
|
||||
|
||||
explicit AssocVector(const key_compare& comp = key_compare(),
|
||||
explicit AssocVector(const key_compare& comp = key_compare(),
|
||||
const A& alloc = A())
|
||||
: Base(alloc), MyCompare(comp)
|
||||
{}
|
||||
|
||||
|
||||
template <class InputIterator>
|
||||
AssocVector(InputIterator first, InputIterator last,
|
||||
const key_compare& comp = key_compare(),
|
||||
AssocVector(InputIterator first, InputIterator last,
|
||||
const key_compare& comp = key_compare(),
|
||||
const A& alloc = A())
|
||||
: Base(first, last, alloc), MyCompare(comp)
|
||||
{
|
||||
MyCompare& me = *this;
|
||||
std::sort(begin(), end(), me);
|
||||
}
|
||||
|
||||
|
||||
AssocVector& operator=(const AssocVector& rhs)
|
||||
{
|
||||
AssocVector(rhs).swap(*this);
|
||||
{
|
||||
AssocVector(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -155,7 +166,7 @@ namespace Loki
|
|||
const_reverse_iterator rbegin() const { return Base::rbegin(); }
|
||||
reverse_iterator rend() { return Base::rend(); }
|
||||
const_reverse_iterator rend() const { return Base::rend(); }
|
||||
|
||||
|
||||
// capacity:
|
||||
bool empty() const { return Base::empty(); }
|
||||
size_type size() const { return Base::size(); }
|
||||
|
@ -182,18 +193,18 @@ namespace Loki
|
|||
//http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/libstdc++/23_containers/howto.html#4
|
||||
iterator insert(iterator pos, const value_type& val)
|
||||
{
|
||||
if( (pos == begin() || this->operator()(*(pos-1),val)) &&
|
||||
if( (pos == begin() || this->operator()(*(pos-1),val)) &&
|
||||
(pos == end() || this->operator()(val, *pos)) )
|
||||
{
|
||||
return Base::insert(pos, val);
|
||||
}
|
||||
return insert(val).first;
|
||||
}
|
||||
|
||||
|
||||
template <class InputIterator>
|
||||
void insert(InputIterator first, InputIterator last)
|
||||
{ for (; first != last; ++first) insert(*first); }
|
||||
|
||||
|
||||
void erase(iterator pos)
|
||||
{ Base::erase(pos); }
|
||||
|
||||
|
@ -215,7 +226,7 @@ namespace Loki
|
|||
MyCompare& rhs = other;
|
||||
std::swap(me, rhs);
|
||||
}
|
||||
|
||||
|
||||
void clear()
|
||||
{ Base::clear(); }
|
||||
|
||||
|
@ -241,7 +252,7 @@ namespace Loki
|
|||
}
|
||||
|
||||
const_iterator find(const key_type& k) const
|
||||
{
|
||||
{
|
||||
const_iterator i(lower_bound(k));
|
||||
if (i != end() && this->operator()(k, i->first))
|
||||
{
|
||||
|
@ -351,7 +362,7 @@ namespace Loki
|
|||
template <class K, class V, class C, class A>
|
||||
void swap(AssocVector<K, V, C, A>& lhs, AssocVector<K, V, C, A>& rhs)
|
||||
{ lhs.swap(rhs); }
|
||||
|
||||
|
||||
} // namespace Loki
|
||||
|
||||
#endif // end file guardian
|
||||
|
|
|
@ -4,13 +4,23 @@
|
|||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The authors make no representations about the suitability of this software
|
||||
// for any purpose. It is provided "as is" without express or implied warranty.
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// This code DOES NOT accompany the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
|
|
|
@ -1,13 +1,26 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The Loki Library
|
||||
// Copyright (c) 2007 by Rich Sposato
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LOKI_CHECK_RETURN_INC_
|
||||
|
|
|
@ -4,13 +4,25 @@
|
|||
// Copyright (c) 2008, 2009 Rich Sposato
|
||||
// The copyright on this file is protected under the terms of the MIT license.
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// The author makes no representations about the suitability of this software
|
||||
// for any purpose. It is provided "as is" without express or implied warranty.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -2,13 +2,26 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2006 Richard Sposato
|
||||
// Copyright (c) 2006 Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The authors make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_CONST_POLICY_INC_
|
||||
#define LOKI_CONST_POLICY_INC_
|
||||
|
|
|
@ -5,9 +5,26 @@
|
|||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
// The author makes no representations about the suitability of this software
|
||||
// for any purpose. It is provided "as is" without express or implied warranty.
|
||||
// Code covered by the MIT License:
|
||||
// Copyright(c) 2010 Shannon Barber
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_DATAGENERATORS_INC_
|
||||
#define LOKI_DATAGENERATORS_INC_
|
||||
|
|
|
@ -2,15 +2,28 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_EMPTYTYPE_INC_
|
||||
#define LOKI_EMPTYTYPE_INC_
|
||||
|
@ -27,18 +40,18 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EmptyType {};
|
||||
|
||||
|
||||
|
||||
|
||||
inline bool operator==(const EmptyType&, const EmptyType&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool operator<(const EmptyType&, const EmptyType&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
inline bool operator>(const EmptyType&, const EmptyType&)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -7,8 +7,24 @@
|
|||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
// The authors make no representations about the suitability of this software
|
||||
// for any purpose. It is provided "as is" without express or implied warranty.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_FACTORYPARM_INC_
|
||||
#define LOKI_FACTORYPARM_INC_
|
||||
|
|
|
@ -2,13 +2,25 @@
|
|||
// The Loki Library
|
||||
// Copyright (C) 2009 Andy Balaam
|
||||
// Copyright (c) 2009 Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LOKI_FOR_EACH_TYPE
|
||||
|
@ -34,7 +46,7 @@ namespace Loki
|
|||
// type of recursive function
|
||||
template <class TList, class Callable>
|
||||
struct ForEachTypeImpl;
|
||||
|
||||
|
||||
// Recursion rule
|
||||
template <class Head, class Tail, class Callable>
|
||||
struct ForEachTypeImpl<Typelist<Head, Tail>, Callable>
|
||||
|
@ -42,7 +54,7 @@ namespace Loki
|
|||
{
|
||||
enum { value = 1 + ForEachTypeImpl<Tail, Callable>::value };
|
||||
|
||||
ForEachTypeImpl( Callable& callable ) : ForEachTypeImpl<Tail, Callable>(callable)
|
||||
ForEachTypeImpl( Callable& callable ) : ForEachTypeImpl<Tail, Callable>(callable)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
callable.operator()<value, Head>();
|
||||
|
@ -50,12 +62,12 @@ namespace Loki
|
|||
callable.template operator()<value, Head>();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
// Recursion end
|
||||
template <class Head, class Callable>
|
||||
struct ForEachTypeImpl<Typelist<Head, NullType>, Callable>
|
||||
struct ForEachTypeImpl<Typelist<Head, NullType>, Callable>
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -70,7 +82,7 @@ namespace Loki
|
|||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,26 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The Loki Library
|
||||
// Copyright (c) 2005 Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_FUNCTION_INC_
|
||||
#define LOKI_FUNCTION_INC_
|
||||
|
@ -30,17 +43,17 @@ namespace Loki
|
|||
///
|
||||
/// \ingroup FunctorGroup
|
||||
/// Allows a boost/TR1 like usage of Functor.
|
||||
///
|
||||
///
|
||||
/// \par Usage
|
||||
///
|
||||
/// - free functions: e.g. \code Function<int(int,int)> f(&freeFunction);
|
||||
/// \endcode
|
||||
/// - member functions: e.g \code Function<int()> f(&object,&ObjectType::memberFunction);
|
||||
/// - member functions: e.g \code Function<int()> f(&object,&ObjectType::memberFunction);
|
||||
/// \endcode
|
||||
///
|
||||
/// see also test/Function/FunctionTest.cpp (the modified test program from boost)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
template<class R = void()>
|
||||
struct Function;
|
||||
|
||||
|
@ -52,29 +65,29 @@ namespace Loki
|
|||
|
||||
Function() : FBase() {}
|
||||
|
||||
Function(const Function& func) : FBase()
|
||||
Function(const Function& func) : FBase()
|
||||
{
|
||||
if( !func.empty())
|
||||
if( !func.empty())
|
||||
FBase::operator=(func);
|
||||
}
|
||||
|
||||
|
||||
// test on emptiness
|
||||
template<class R2>
|
||||
Function(Function<R2()> func) : FBase()
|
||||
template<class R2>
|
||||
Function(Function<R2()> func) : FBase()
|
||||
{
|
||||
if(!func.empty())
|
||||
FBase::operator=(func);
|
||||
}
|
||||
|
||||
|
||||
// clear by '= 0'
|
||||
Function(const int i) : FBase()
|
||||
{
|
||||
{
|
||||
if(i==0)
|
||||
FBase::clear();
|
||||
else
|
||||
throw std::runtime_error("Loki::Function(const int i): i!=0");
|
||||
}
|
||||
|
||||
|
||||
template<class Func>
|
||||
Function(Func func) : FBase(func) {}
|
||||
|
||||
|
@ -113,7 +126,7 @@ namespace Loki
|
|||
template<class Host, class Func> \
|
||||
Function(const Host& host, const Func& func): FBase(host,func) {}
|
||||
|
||||
|
||||
|
||||
#define LOKI_FUNCTION_R2_CTOR_BODY \
|
||||
\
|
||||
: FBase() \
|
||||
|
@ -132,77 +145,77 @@ namespace Loki
|
|||
: public Loki::Functor<>
|
||||
{
|
||||
typedef Functor<> FBase;
|
||||
|
||||
|
||||
template<class R2>
|
||||
Function(Function<R2()> func)
|
||||
Function(Function<R2()> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY // if compilation breaks here then
|
||||
LOKI_FUNCTION_BODY // if compilation breaks here then
|
||||
// Function.h was not included before
|
||||
// Functor.h, check your include order
|
||||
// or define LOKI_ENABLE_FUNCTION
|
||||
// or define LOKI_ENABLE_FUNCTION
|
||||
};
|
||||
|
||||
template<class R,class P01>
|
||||
struct Function<R(P01)>
|
||||
struct Function<R(P01)>
|
||||
: public Loki::Functor<R, Seq<P01> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01> > FBase;
|
||||
|
||||
|
||||
template<class R2,class Q01>
|
||||
Function(Function<R2(Q01)> func)
|
||||
Function(Function<R2(Q01)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
};
|
||||
|
||||
template<class R,class P01,class P02>
|
||||
struct Function<R(P01,P02)>
|
||||
struct Function<R(P01,P02)>
|
||||
: public Functor<R, Seq<P01,P02> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02> > FBase;
|
||||
|
||||
template<class R2,class Q01, class Q02>
|
||||
Function(Function<R2(Q01,Q02)> func)
|
||||
Function(Function<R2(Q01,Q02)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
};
|
||||
|
||||
template<class R,class P01,class P02, class P03>
|
||||
struct Function<R(P01,P02,P03)>
|
||||
struct Function<R(P01,P02,P03)>
|
||||
: public Functor<R, Seq<P01,P02,P03> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03> > FBase;
|
||||
|
||||
template<class R2,class Q01, class Q02,class Q03>
|
||||
Function(Function<R2(Q01,Q02,Q03)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
};
|
||||
|
||||
template<class R,class P01,class P02, class P03,class P04>
|
||||
struct Function<R(P01,P02,P03,P04)>
|
||||
struct Function<R(P01,P02,P03,P04)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04> > FBase;
|
||||
|
||||
template<class R2,class Q01,class Q02, class Q03,class Q04>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
};
|
||||
|
||||
template<class R,class P01,class P02, class P03,class P04,class P05>
|
||||
struct Function<R(P01,P02,P03,P04,P05)>
|
||||
struct Function<R(P01,P02,P03,P04,P05)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05> > FBase;
|
||||
|
||||
template<class R2,class Q01,class Q02, class Q03,class Q04,class Q05>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -210,14 +223,14 @@ namespace Loki
|
|||
|
||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06> > FBase;
|
||||
|
||||
|
||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -225,14 +238,14 @@ namespace Loki
|
|||
|
||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06,class P07>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> > FBase;
|
||||
|
||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06,class Q07>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -240,14 +253,14 @@ namespace Loki
|
|||
|
||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06,class P07, class P08>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> > FBase;
|
||||
|
||||
|
||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06,class Q07, class Q08>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -255,14 +268,14 @@ namespace Loki
|
|||
|
||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06,class P07, class P08,class P09>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09 > > FBase;
|
||||
|
||||
|
||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06,class Q07, class Q08,class Q09>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -270,14 +283,14 @@ namespace Loki
|
|||
|
||||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06,class P07, class P08,class P09,class P10>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> > FBase;
|
||||
|
||||
|
||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06,class Q07, class Q08,class Q09,class Q10>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -286,15 +299,15 @@ namespace Loki
|
|||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06,class P07, class P08,class P09,class P10,
|
||||
class P11>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >FBase;
|
||||
|
||||
|
||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||
class Q11>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -303,15 +316,15 @@ namespace Loki
|
|||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06,class P07, class P08,class P09,class P10,
|
||||
class P11,class P12>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> > FBase;
|
||||
|
||||
|
||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||
class Q11,class Q12>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -320,15 +333,15 @@ namespace Loki
|
|||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06,class P07, class P08,class P09,class P10,
|
||||
class P11,class P12, class P13>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> > FBase;
|
||||
|
||||
|
||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||
class Q11,class Q12, class Q13>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -337,14 +350,14 @@ namespace Loki
|
|||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06,class P07, class P08,class P09,class P10,
|
||||
class P11,class P12, class P13,class P14>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> > FBase;
|
||||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||
class Q11,class Q12, class Q13,class Q14>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
@ -353,7 +366,7 @@ namespace Loki
|
|||
template<class R, class P01,class P02, class P03,class P04,class P05,
|
||||
class P06,class P07, class P08,class P09,class P10,
|
||||
class P11,class P12, class P13,class P14,class P15>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15)>
|
||||
struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15)>
|
||||
: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> >
|
||||
{
|
||||
typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> > FBase;
|
||||
|
@ -361,7 +374,7 @@ namespace Loki
|
|||
template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
|
||||
class Q06,class Q07, class Q08,class Q09,class Q10,
|
||||
class Q11,class Q12, class Q13,class Q14,class Q15>
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14,Q15)> func)
|
||||
Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14,Q15)> func)
|
||||
LOKI_FUNCTION_R2_CTOR_BODY
|
||||
|
||||
LOKI_FUNCTION_BODY
|
||||
|
|
|
@ -2,15 +2,28 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_FUNCTOR_INC_
|
||||
#define LOKI_FUNCTOR_INC_
|
||||
|
@ -48,7 +61,7 @@ namespace Loki
|
|||
namespace Private
|
||||
{
|
||||
template <typename R, template <class, class> class ThreadingModel>
|
||||
struct FunctorImplBase
|
||||
struct FunctorImplBase
|
||||
#ifdef LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT
|
||||
{
|
||||
#else
|
||||
|
@ -98,12 +111,12 @@ namespace Loki
|
|||
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
|
||||
|
||||
virtual bool operator==(const FunctorImplBase&) const = 0;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// macro LOKI_DEFINE_CLONE_FUNCTORIMPL
|
||||
// Implements the DoClone function for a functor implementation
|
||||
|
@ -121,7 +134,7 @@ namespace Loki
|
|||
// Specializations of FunctorImpl for up to 15 parameters follow
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename R, class TList,
|
||||
template <typename R, class TList,
|
||||
template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>
|
||||
class FunctorImpl;
|
||||
|
||||
|
@ -159,7 +172,7 @@ namespace Loki
|
|||
// Specialization for 2 parameters
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename R, typename P1, typename P2,
|
||||
template <typename R, typename P1, typename P2,
|
||||
template <class, class> class ThreadingModel>
|
||||
class FunctorImpl<R, Seq<P1, P2>, ThreadingModel>
|
||||
: public Private::FunctorImplBase<R, ThreadingModel>
|
||||
|
@ -271,7 +284,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
||||
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
||||
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7) = 0;
|
||||
};
|
||||
|
||||
|
@ -297,7 +310,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
||||
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
||||
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8) = 0;
|
||||
};
|
||||
|
||||
|
@ -324,7 +337,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
||||
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
||||
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9) = 0;
|
||||
};
|
||||
|
||||
|
@ -353,7 +366,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
||||
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
||||
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10) = 0;
|
||||
};
|
||||
|
||||
|
@ -384,7 +397,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
||||
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
||||
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11) = 0;
|
||||
};
|
||||
|
||||
|
@ -416,7 +429,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
||||
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
||||
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12) = 0;
|
||||
};
|
||||
|
||||
|
@ -449,7 +462,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
||||
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
||||
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13) = 0;
|
||||
};
|
||||
|
||||
|
@ -484,7 +497,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
||||
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
||||
typedef typename TypeTraits<P14>::ParameterType Parm14;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14) = 0;
|
||||
};
|
||||
|
||||
|
@ -520,7 +533,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
||||
typedef typename TypeTraits<P14>::ParameterType Parm14;
|
||||
typedef typename TypeTraits<P15>::ParameterType Parm15;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14,
|
||||
Parm15) = 0;
|
||||
};
|
||||
|
@ -547,7 +560,7 @@ namespace Loki
|
|||
// Specialization for 2 parameters
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename R, typename P1, typename P2,
|
||||
template <typename R, typename P1, typename P2,
|
||||
template <class, class> class ThreadingModel>
|
||||
class FunctorImpl<R, LOKI_TYPELIST_2(P1, P2), ThreadingModel>
|
||||
: public Private::FunctorImplBase<R, ThreadingModel>
|
||||
|
@ -659,7 +672,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P5>::ParameterType Parm5;
|
||||
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
||||
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7) = 0;
|
||||
};
|
||||
|
||||
|
@ -685,7 +698,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P6>::ParameterType Parm6;
|
||||
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
||||
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8) = 0;
|
||||
};
|
||||
|
||||
|
@ -712,7 +725,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P7>::ParameterType Parm7;
|
||||
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
||||
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9) = 0;
|
||||
};
|
||||
|
||||
|
@ -741,7 +754,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P8>::ParameterType Parm8;
|
||||
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
||||
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10) = 0;
|
||||
};
|
||||
|
||||
|
@ -772,7 +785,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P9>::ParameterType Parm9;
|
||||
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
||||
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11) = 0;
|
||||
};
|
||||
|
||||
|
@ -804,7 +817,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P10>::ParameterType Parm10;
|
||||
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
||||
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12) = 0;
|
||||
};
|
||||
|
||||
|
@ -837,7 +850,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P11>::ParameterType Parm11;
|
||||
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
||||
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13) = 0;
|
||||
};
|
||||
|
||||
|
@ -872,7 +885,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P12>::ParameterType Parm12;
|
||||
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
||||
typedef typename TypeTraits<P14>::ParameterType Parm14;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14) = 0;
|
||||
};
|
||||
|
||||
|
@ -908,7 +921,7 @@ namespace Loki
|
|||
typedef typename TypeTraits<P13>::ParameterType Parm13;
|
||||
typedef typename TypeTraits<P14>::ParameterType Parm14;
|
||||
typedef typename TypeTraits<P15>::ParameterType Parm15;
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
|
||||
Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14,
|
||||
Parm15) = 0;
|
||||
};
|
||||
|
@ -943,9 +956,9 @@ namespace Loki
|
|||
typedef typename Base::Parm13 Parm13;
|
||||
typedef typename Base::Parm14 Parm14;
|
||||
typedef typename Base::Parm15 Parm15;
|
||||
|
||||
|
||||
FunctorHandler(const Fun& fun) : f_(fun) {}
|
||||
|
||||
|
||||
LOKI_DEFINE_CLONE_FUNCTORIMPL(FunctorHandler)
|
||||
|
||||
|
||||
|
@ -954,7 +967,7 @@ namespace Loki
|
|||
|
||||
bool operator==(const typename Base::FunctorImplBaseType& rhs) const
|
||||
{
|
||||
// there is no static information if Functor holds a member function
|
||||
// there is no static information if Functor holds a member function
|
||||
// or a free function; this is the main difference to tr1::function
|
||||
if(typeid(*this) != typeid(rhs))
|
||||
return false; // cannot be equal
|
||||
|
@ -966,79 +979,79 @@ namespace Loki
|
|||
}
|
||||
#endif
|
||||
// operator() implementations for up to 15 arguments
|
||||
|
||||
|
||||
ResultType operator()()
|
||||
{ return f_(); }
|
||||
|
||||
ResultType operator()(Parm1 p1)
|
||||
{ return f_(p1); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2)
|
||||
{ return f_(p1, p2); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
|
||||
{ return f_(p1, p2, p3); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
|
||||
{ return f_(p1, p2, p3, p4); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
|
||||
{ return f_(p1, p2, p3, p4, p5); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6)
|
||||
{ return f_(p1, p2, p3, p4, p5, p6); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7)
|
||||
{ return f_(p1, p2, p3, p4, p5, p6, p7); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8)
|
||||
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
|
||||
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
|
||||
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
|
||||
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12)
|
||||
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13)
|
||||
{ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13, Parm14 p14)
|
||||
{
|
||||
return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
p14);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
|
||||
{
|
||||
return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
p14, p15);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Fun f_;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template FunctorHandler
|
||||
// Wraps pointers to member functions
|
||||
|
@ -1068,10 +1081,10 @@ namespace Loki
|
|||
typedef typename Base::Parm14 Parm14;
|
||||
typedef typename Base::Parm15 Parm15;
|
||||
|
||||
MemFunHandler(const PointerToObj& pObj, PointerToMemFn pMemFn)
|
||||
MemFunHandler(const PointerToObj& pObj, PointerToMemFn pMemFn)
|
||||
: pObj_(pObj), pMemFn_(pMemFn)
|
||||
{}
|
||||
|
||||
|
||||
LOKI_DEFINE_CLONE_FUNCTORIMPL(MemFunHandler)
|
||||
|
||||
|
||||
|
@ -1080,97 +1093,97 @@ namespace Loki
|
|||
bool operator==(const typename Base::FunctorImplBaseType& rhs) const
|
||||
{
|
||||
if(typeid(*this) != typeid(rhs))
|
||||
return false; // cannot be equal
|
||||
return false; // cannot be equal
|
||||
|
||||
const MemFunHandler& mfh = static_cast<const MemFunHandler&>(rhs);
|
||||
// if this line gives a compiler error, you are using a function object.
|
||||
// you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
|
||||
return pObj_==mfh.pObj_ && pMemFn_==mfh.pMemFn_;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ResultType operator()()
|
||||
{ return ((*pObj_).*pMemFn_)(); }
|
||||
|
||||
ResultType operator()(Parm1 p1)
|
||||
{ return ((*pObj_).*pMemFn_)(p1); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2)
|
||||
{ return ((*pObj_).*pMemFn_)(p1, p2); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
|
||||
{ return ((*pObj_).*pMemFn_)(p1, p2, p3); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
|
||||
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
|
||||
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6)
|
||||
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7)
|
||||
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8)
|
||||
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
|
||||
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
|
||||
{ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
|
||||
{
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
p11);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12)
|
||||
{
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
p11, p12);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13)
|
||||
{
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
p11, p12, p13);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13, Parm14 p14)
|
||||
{
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
p11, p12, p13, p14);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
|
||||
{
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
|
||||
p11, p12, p13, p14, p15);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
PointerToObj pObj_;
|
||||
PointerToMemFn pMemFn_;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TR1 exception
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1188,7 +1201,7 @@ namespace Loki
|
|||
|
||||
#else
|
||||
|
||||
#define LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
#define LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1199,9 +1212,9 @@ namespace Loki
|
|||
/// A generalized functor implementation with value semantics
|
||||
///
|
||||
/// \par Macro: LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT
|
||||
/// Define
|
||||
/// Define
|
||||
/// \code LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT \endcode
|
||||
/// to avoid static instantiation/delete
|
||||
/// to avoid static instantiation/delete
|
||||
/// order problems.
|
||||
/// It often helps against crashes when using static Functors and multi threading.
|
||||
/// Defining also removes problems when unloading Dlls which hosts
|
||||
|
@ -1210,7 +1223,7 @@ namespace Loki
|
|||
/// \par Macro: LOKI_FUNCTORS_ARE_COMPARABLE
|
||||
/// To enable the operator== define the macro
|
||||
/// \code LOKI_FUNCTORS_ARE_COMPARABLE \endcode
|
||||
/// The macro is disabled by default, because it breaks compiling functor
|
||||
/// The macro is disabled by default, because it breaks compiling functor
|
||||
/// objects which have no operator== implemented, keep in mind when you enable
|
||||
/// operator==.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1243,13 +1256,13 @@ namespace Loki
|
|||
|
||||
Functor() : spImpl_(0)
|
||||
{}
|
||||
|
||||
|
||||
Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get()))
|
||||
{}
|
||||
|
||||
|
||||
Functor(std::auto_ptr<Impl> spImpl) : spImpl_(spImpl)
|
||||
{}
|
||||
|
||||
|
||||
template <typename Fun>
|
||||
Functor(Fun fun)
|
||||
: spImpl_(new FunctorHandler<Functor, Fun>(fun))
|
||||
|
@ -1313,90 +1326,90 @@ namespace Loki
|
|||
ResultType operator()() const
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)();
|
||||
return (*spImpl_)();
|
||||
}
|
||||
|
||||
ResultType operator()(Parm1 p1) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1);
|
||||
return (*spImpl_)(p1);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2);
|
||||
return (*spImpl_)(p1, p2);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3);
|
||||
return (*spImpl_)(p1, p2, p3);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4);
|
||||
return (*spImpl_)(p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5);
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6);
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7);
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8);
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11) const
|
||||
{
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12) const
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||
p12);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13) const
|
||||
|
@ -1405,33 +1418,33 @@ namespace Loki
|
|||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||
p12, p13);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13, Parm14 p14) const
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||
p12, p13, p14);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15) const
|
||||
{
|
||||
LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||
return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
|
||||
p12, p13, p14, p15);
|
||||
}
|
||||
|
||||
private:
|
||||
std::auto_ptr<Impl> spImpl_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BindersFirst and Chainer
|
||||
//
|
||||
// BindersFirst and Chainer
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -1454,7 +1467,7 @@ namespace Loki
|
|||
|
||||
typedef typename BoundFunctorType::Impl Impl;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
|
@ -1465,26 +1478,26 @@ namespace Loki
|
|||
{
|
||||
typedef typename TypeTraits<T>::ParameterType RefOrValue;
|
||||
};
|
||||
|
||||
|
||||
template <typename R, class TList, template <class, class> class ThreadingModel>
|
||||
struct BinderFirstBoundTypeStorage< Functor<R, TList, ThreadingModel> >
|
||||
{
|
||||
typedef Functor<R, TList, ThreadingModel> OriginalFunctor;
|
||||
typedef const typename TypeTraits<OriginalFunctor>::ReferredType RefOrValue;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
} // namespace Private
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \class BinderFirst
|
||||
///
|
||||
///
|
||||
/// \ingroup FunctorGroup
|
||||
/// Binds the first parameter of a Functor object to a specific value
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class OriginalFunctor>
|
||||
class BinderFirst
|
||||
class BinderFirst
|
||||
: public Private::BinderFirstTraits<OriginalFunctor>::Impl
|
||||
{
|
||||
typedef typename Private::BinderFirstTraits<OriginalFunctor>::Impl Base;
|
||||
|
@ -1497,7 +1510,7 @@ namespace Loki
|
|||
::OriginalParm1>
|
||||
::RefOrValue
|
||||
BoundTypeStorage;
|
||||
|
||||
|
||||
typedef typename OriginalFunctor::Parm2 Parm1;
|
||||
typedef typename OriginalFunctor::Parm3 Parm2;
|
||||
typedef typename OriginalFunctor::Parm4 Parm3;
|
||||
|
@ -1515,7 +1528,7 @@ namespace Loki
|
|||
typedef EmptyType Parm15;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
BinderFirst(const OriginalFunctor& fun, BoundType bound)
|
||||
: f_(fun), b_(bound)
|
||||
{}
|
||||
|
@ -1523,11 +1536,11 @@ namespace Loki
|
|||
LOKI_DEFINE_CLONE_FUNCTORIMPL(BinderFirst)
|
||||
|
||||
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
|
||||
|
||||
|
||||
bool operator==(const typename Base::FunctorImplBaseType& rhs) const
|
||||
{
|
||||
if(typeid(*this) != typeid(rhs))
|
||||
return false; // cannot be equal
|
||||
return false; // cannot be equal
|
||||
// if this line gives a compiler error, you are using a function object.
|
||||
// you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
|
||||
return f_ == ((static_cast<const BinderFirst&> (rhs)).f_) &&
|
||||
|
@ -1536,72 +1549,72 @@ namespace Loki
|
|||
#endif
|
||||
|
||||
// operator() implementations for up to 15 arguments
|
||||
|
||||
|
||||
ResultType operator()()
|
||||
{ return f_(b_); }
|
||||
|
||||
ResultType operator()(Parm1 p1)
|
||||
{ return f_(b_, p1); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2)
|
||||
{ return f_(b_, p1, p2); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
|
||||
{ return f_(b_, p1, p2, p3); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
|
||||
{ return f_(b_, p1, p2, p3, p4); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
|
||||
{ return f_(b_, p1, p2, p3, p4, p5); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6)
|
||||
{ return f_(b_, p1, p2, p3, p4, p5, p6); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7)
|
||||
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8)
|
||||
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
|
||||
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
|
||||
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
|
||||
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12)
|
||||
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13)
|
||||
{ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13, Parm14 p14)
|
||||
{
|
||||
return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
p14);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
OriginalFunctor f_;
|
||||
BoundTypeStorage b_;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Binds the first parameter of a Functor object to a specific value
|
||||
/// \ingroup FunctorGroup
|
||||
|
@ -1610,12 +1623,12 @@ namespace Loki
|
|||
template <class Fctor>
|
||||
typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
|
||||
BindFirst(
|
||||
const Fctor& fun,
|
||||
const Fctor& fun,
|
||||
typename Fctor::Parm1 bound)
|
||||
{
|
||||
typedef typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
|
||||
Outgoing;
|
||||
|
||||
|
||||
return Outgoing(std::auto_ptr<typename Outgoing::Impl>(
|
||||
new BinderFirst<Fctor>(fun, bound)));
|
||||
}
|
||||
|
@ -1649,17 +1662,17 @@ namespace Loki
|
|||
typedef typename Base::Parm13 Parm13;
|
||||
typedef typename Base::Parm14 Parm14;
|
||||
typedef typename Base::Parm15 Parm15;
|
||||
|
||||
|
||||
Chainer(const Fun1& fun1, const Fun2& fun2) : f1_(fun1), f2_(fun2) {}
|
||||
|
||||
LOKI_DEFINE_CLONE_FUNCTORIMPL(Chainer)
|
||||
|
||||
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
|
||||
|
||||
|
||||
bool operator==(const typename Base::Impl::FunctorImplBaseType& rhs) const
|
||||
{
|
||||
if(typeid(*this) != typeid(rhs))
|
||||
return false; // cannot be equal
|
||||
return false; // cannot be equal
|
||||
// if this line gives a compiler error, you are using a function object.
|
||||
// you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
|
||||
return f1_ == ((static_cast<const Chainer&> (rhs)).f2_) &&
|
||||
|
@ -1674,58 +1687,58 @@ namespace Loki
|
|||
|
||||
ResultType operator()(Parm1 p1)
|
||||
{ return f1_(p1), f2_(p1); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2)
|
||||
{ return f1_(p1, p2), f2_(p1, p2); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
|
||||
{ return f1_(p1, p2, p3), f2_(p1, p2, p3); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
|
||||
{ return f1_(p1, p2, p3, p4), f2_(p1, p2, p3, p4); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
|
||||
{ return f1_(p1, p2, p3, p4, p5), f2_(p1, p2, p3, p4, p5); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6)
|
||||
{ return f1_(p1, p2, p3, p4, p5, p6), f2_(p1, p2, p3, p4, p5, p6); }
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7)
|
||||
{
|
||||
return f1_(p1, p2, p3, p4, p5, p6, p7),
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8)
|
||||
{
|
||||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8),
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
|
||||
{
|
||||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9),
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
|
||||
{
|
||||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10),
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
|
||||
{
|
||||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11),
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12)
|
||||
|
@ -1733,7 +1746,7 @@ namespace Loki
|
|||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12),
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13)
|
||||
|
@ -1741,32 +1754,32 @@ namespace Loki
|
|||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13),
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13, Parm14 p14)
|
||||
{
|
||||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
p14),
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
p14);
|
||||
}
|
||||
|
||||
|
||||
ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
|
||||
Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
|
||||
Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
|
||||
{
|
||||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
p14, p15),
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
|
||||
p14, p15);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Fun1 f1_;
|
||||
Fun2 f2_;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Chains two functor calls one after another
|
||||
/// \ingroup FunctorGroup
|
||||
|
|
|
@ -4,13 +4,25 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_HIERARCHYGENERATORS_INC_
|
||||
#define LOKI_HIERARCHYGENERATORS_INC_
|
||||
|
|
|
@ -4,16 +4,26 @@
|
|||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The authors make no representations about the suitability of this software
|
||||
// for any purpose. It is provided "as is" without express or implied warranty.
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// This code DOES NOT accompany the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -39,7 +49,7 @@ namespace Loki
|
|||
|
||||
template<class F, typename I>
|
||||
bool operator<(const Key<F, I> &k1, const Key<F, I> &k2);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A Key class
|
||||
|
@ -84,7 +94,7 @@ namespace Loki
|
|||
Parm13 p13;
|
||||
Parm14 p14;
|
||||
Parm15 p15;
|
||||
|
||||
|
||||
// member functions
|
||||
Key() : count(-1)
|
||||
{
|
||||
|
@ -94,7 +104,7 @@ namespace Loki
|
|||
{
|
||||
this->id = id;
|
||||
}
|
||||
|
||||
|
||||
Key(const IdentifierType& id,
|
||||
Parm1 &p1) : count(1)
|
||||
{
|
||||
|
@ -197,7 +207,7 @@ namespace Loki
|
|||
this->p8 = p8;
|
||||
this->p9 = p9;
|
||||
}
|
||||
|
||||
|
||||
Key(const IdentifierType& id,
|
||||
Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
|
||||
Parm6 &p6, Parm7 &p7, Parm8 &p8, Parm9 &p9,Parm10 &p10) : count(10)
|
||||
|
@ -322,12 +332,12 @@ namespace Loki
|
|||
|
||||
template<class F, typename I>
|
||||
friend bool operator==(const Key<F, I> &k1, const Key<F, I> &k2);
|
||||
|
||||
|
||||
template<class F, typename I>
|
||||
friend bool operator<(const Key<F, I> &k1, const Key<F, I> &k2);
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class F, typename I>
|
||||
bool operator==(const Key<F, I> &k1, const Key<F, I> &k2)
|
||||
{
|
||||
|
@ -342,196 +352,196 @@ namespace Loki
|
|||
else
|
||||
return false;
|
||||
case 1:
|
||||
if( (k1.id == k2.id) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 2:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 3:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 4:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 5:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 6:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 7:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 8:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 9:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 10:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 11:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
(k1.p11 == k2.p11) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 12:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
(k1.p11 == k2.p11) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
(k1.p11 == k2.p11) &&
|
||||
(k1.p12 == k2.p12) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 13:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
(k1.p11 == k2.p11) &&
|
||||
(k1.p12 == k2.p12) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
(k1.p11 == k2.p11) &&
|
||||
(k1.p12 == k2.p12) &&
|
||||
(k1.p13 == k2.p13) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 14:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
(k1.p11 == k2.p11) &&
|
||||
(k1.p12 == k2.p12) &&
|
||||
(k1.p13 == k2.p13) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
(k1.p11 == k2.p11) &&
|
||||
(k1.p12 == k2.p12) &&
|
||||
(k1.p13 == k2.p13) &&
|
||||
(k1.p14 == k2.p14) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 15:
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
(k1.p11 == k2.p11) &&
|
||||
(k1.p12 == k2.p12) &&
|
||||
(k1.p13 == k2.p13) &&
|
||||
(k1.p14 == k2.p14) &&
|
||||
if( (k1.id == k2.id) &&
|
||||
(k1.p1 == k2.p1) &&
|
||||
(k1.p2 == k2.p2) &&
|
||||
(k1.p3 == k2.p3) &&
|
||||
(k1.p4 == k2.p4) &&
|
||||
(k1.p5 == k2.p5) &&
|
||||
(k1.p6 == k2.p6) &&
|
||||
(k1.p7 == k2.p7) &&
|
||||
(k1.p8 == k2.p8) &&
|
||||
(k1.p9 == k2.p9) &&
|
||||
(k1.p10 == k2.p10) &&
|
||||
(k1.p11 == k2.p11) &&
|
||||
(k1.p12 == k2.p12) &&
|
||||
(k1.p13 == k2.p13) &&
|
||||
(k1.p14 == k2.p14) &&
|
||||
(k1.p15 == k2.p15) )
|
||||
return true;
|
||||
else
|
||||
|
@ -557,196 +567,196 @@ namespace Loki
|
|||
else
|
||||
return false;
|
||||
case 1:
|
||||
if( (k1.id < k2.id) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 2:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 3:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 4:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 5:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 6:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 7:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 8:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 9:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 10:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 11:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
(k1.p11 < k2.p11) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 12:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
(k1.p11 < k2.p11) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
(k1.p11 < k2.p11) ||
|
||||
(k1.p12 < k2.p12) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 13:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
(k1.p11 < k2.p11) ||
|
||||
(k1.p12 < k2.p12) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
(k1.p11 < k2.p11) ||
|
||||
(k1.p12 < k2.p12) ||
|
||||
(k1.p13 < k2.p13) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 14:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
(k1.p11 < k2.p11) ||
|
||||
(k1.p12 < k2.p12) ||
|
||||
(k1.p13 < k2.p13) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
(k1.p11 < k2.p11) ||
|
||||
(k1.p12 < k2.p12) ||
|
||||
(k1.p13 < k2.p13) ||
|
||||
(k1.p14 < k2.p14) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case 15:
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
(k1.p11 < k2.p11) ||
|
||||
(k1.p12 < k2.p12) ||
|
||||
(k1.p13 < k2.p13) ||
|
||||
(k1.p14 < k2.p14) ||
|
||||
if( (k1.id < k2.id) ||
|
||||
(k1.p1 < k2.p1) ||
|
||||
(k1.p2 < k2.p2) ||
|
||||
(k1.p3 < k2.p3) ||
|
||||
(k1.p4 < k2.p4) ||
|
||||
(k1.p5 < k2.p5) ||
|
||||
(k1.p6 < k2.p6) ||
|
||||
(k1.p7 < k2.p7) ||
|
||||
(k1.p8 < k2.p8) ||
|
||||
(k1.p9 < k2.p9) ||
|
||||
(k1.p10 < k2.p10) ||
|
||||
(k1.p11 < k2.p11) ||
|
||||
(k1.p12 < k2.p12) ||
|
||||
(k1.p13 < k2.p13) ||
|
||||
(k1.p14 < k2.p14) ||
|
||||
(k1.p15 < k2.p15) )
|
||||
return true;
|
||||
else
|
||||
|
@ -756,7 +766,7 @@ namespace Loki
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Loki
|
||||
|
||||
|
|
|
@ -2,15 +2,26 @@
|
|||
//
|
||||
// LevelMutex facility for the Loki Library
|
||||
// Copyright (c) 2008, 2009 Richard Sposato
|
||||
// The copyright on this file is protected under the terms of the MIT license.
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// The author makes no representations about the suitability of this software
|
||||
// for any purpose. It is provided "as is" without express or implied warranty.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -7,13 +7,27 @@
|
|||
// for You" by Alexandrescu, Andrei.
|
||||
// Published in the February 2001 issue of the C/C++ Users Journal.
|
||||
// http://www.cuj.com/documents/s=7998/cujcexp1902alexandr/
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// Prepared for Loki library by Richard Sposato
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_LOCKING_PTR_INC_
|
||||
|
@ -36,7 +50,7 @@ namespace Loki
|
|||
the mutex type as a LockingPolicy class. The only requirements for a
|
||||
LockingPolicy class are to provide Lock and Unlock methods.
|
||||
*/
|
||||
template < typename SharedObject, typename LockingPolicy = LOKI_DEFAULT_MUTEX,
|
||||
template < typename SharedObject, typename LockingPolicy = LOKI_DEFAULT_MUTEX,
|
||||
template<class> class ConstPolicy = LOKI_DEFAULT_CONSTNESS >
|
||||
class LockingPtr
|
||||
{
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The Loki Library
|
||||
// Copyright (c) 2006 by Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_LOKIEXPORT_INC_
|
||||
#define LOKI_LOKIEXPORT_INC_
|
||||
|
@ -19,10 +31,10 @@
|
|||
|
||||
#ifdef _HAVE_GCC_VISIBILITY
|
||||
#define LOKI_EXPORT_SPEC __attribute__ ((visibility("default")))
|
||||
#define LOKI_IMPORT_SPEC
|
||||
#define LOKI_IMPORT_SPEC
|
||||
#else
|
||||
#define LOKI_EXPORT_SPEC
|
||||
#define LOKI_IMPORT_SPEC
|
||||
#define LOKI_IMPORT_SPEC
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
@ -31,8 +43,8 @@
|
|||
#define LOKI_EXPORT_SPEC __declspec(dllexport)
|
||||
#define LOKI_IMPORT_SPEC __declspec(dllimport)
|
||||
#else
|
||||
#define LOKI_EXPORT_SPEC
|
||||
#define LOKI_IMPORT_SPEC
|
||||
#define LOKI_EXPORT_SPEC
|
||||
#define LOKI_IMPORT_SPEC
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,13 +4,26 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_LOKITYPEINFO_INC_
|
||||
#define LOKI_LOKITYPEINFO_INC_
|
||||
|
|
|
@ -4,13 +4,26 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_MULTIMETHODS_INC_
|
||||
#define LOKI_MULTIMETHODS_INC_
|
||||
|
|
|
@ -2,15 +2,27 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_NULLTYPE_INC_
|
||||
#define LOKI_NULLTYPE_INC_
|
||||
|
@ -23,11 +35,11 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class NullType
|
||||
// Used as a placeholder for "no type here"
|
||||
// Useful as an end marker in typelists
|
||||
// Useful as an end marker in typelists
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class NullType {};
|
||||
|
||||
|
||||
} // namespace Loki
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The Loki Library
|
||||
// Copyright (c) 2005 Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_ORDEREDSTATIC_INC_
|
||||
#define LOKI_ORDEREDSTATIC_INC_
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The Loki Library
|
||||
// Copyright (c) 2006 Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_PIMPL_INC_
|
||||
#define LOKI_PIMPL_INC_
|
||||
|
@ -15,7 +27,7 @@
|
|||
// $Id$
|
||||
|
||||
|
||||
/// \defgroup PimplGroup Pimpl
|
||||
/// \defgroup PimplGroup Pimpl
|
||||
|
||||
#ifndef LOKI_INHERITED_PIMPL_NAME
|
||||
#define LOKI_INHERITED_PIMPL_NAME d
|
||||
|
@ -45,7 +57,7 @@ namespace Loki
|
|||
T& operator*() { return *ptr_; }
|
||||
const T* operator->() const { return ptr_; }
|
||||
const T& operator*() const { return *ptr_; }
|
||||
|
||||
|
||||
private:
|
||||
ConstPropPtr();
|
||||
ConstPropPtr(const ConstPropPtr&);
|
||||
|
@ -62,17 +74,17 @@ namespace Loki
|
|||
/// Implements the Pimpl idiom. It's a wrapper for a smart pointer which
|
||||
/// automatically creates and deletes the implementation object and adds
|
||||
/// const propagation to the smart pointer.
|
||||
///
|
||||
///
|
||||
/// \par Usage
|
||||
/// see test/Pimpl
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template
|
||||
<
|
||||
class T,
|
||||
<
|
||||
class T,
|
||||
typename Pointer = ConstPropPtr<T>
|
||||
>
|
||||
class Pimpl
|
||||
class Pimpl
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -86,9 +98,9 @@ namespace Loki
|
|||
// Don't compile with incomplete type
|
||||
//
|
||||
// If compilation breaks here make sure
|
||||
// the compiler does not auto-generate the
|
||||
// the compiler does not auto-generate the
|
||||
// destructor of the class hosting the pimpl:
|
||||
// - implement the destructor of the class
|
||||
// - implement the destructor of the class
|
||||
// - don't inline the destructor
|
||||
typedef char T_must_be_defined[sizeof(T) ? 1 : -1 ];
|
||||
}
|
||||
|
@ -134,8 +146,8 @@ namespace Loki
|
|||
|
||||
|
||||
template<class T, typename Pointer = ConstPropPtr<T> >
|
||||
struct PimplOwner
|
||||
{
|
||||
struct PimplOwner
|
||||
{
|
||||
Pimpl<T,Pointer> LOKI_INHERITED_PIMPL_NAME;
|
||||
};
|
||||
|
||||
|
@ -144,7 +156,7 @@ namespace Loki
|
|||
/// \class ImplOf
|
||||
///
|
||||
/// \ingroup PimplGroup
|
||||
/// Convenience template for the
|
||||
/// Convenience template for the
|
||||
/// implementations which Pimpl points to.
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
@ -191,7 +203,7 @@ namespace Loki
|
|||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // end file guardian
|
||||
|
|
|
@ -2,13 +2,25 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2006 Richard Sposato
|
||||
// Copyright (c) 2006 Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The authors make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_REFTOVALUE_INC_
|
||||
#define LOKI_REFTOVALUE_INC_
|
||||
|
@ -22,23 +34,23 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \class RefToValue
|
||||
///
|
||||
/// \ingroup SmartPointerGroup
|
||||
/// \ingroup SmartPointerGroup
|
||||
/// Transports a reference as a value
|
||||
/// Serves to implement the Colvin/Gibbons trick for SmartPtr/ScopeGuard
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class T>
|
||||
class RefToValue
|
||||
{
|
||||
{
|
||||
public:
|
||||
|
||||
RefToValue(T& ref) : ref_(ref)
|
||||
|
||||
RefToValue(T& ref) : ref_(ref)
|
||||
{}
|
||||
|
||||
RefToValue(const RefToValue& rhs) : ref_(rhs.ref_)
|
||||
{}
|
||||
|
||||
operator T& () const
|
||||
operator T& () const
|
||||
{
|
||||
return ref_;
|
||||
}
|
||||
|
@ -47,13 +59,13 @@ namespace Loki
|
|||
// Disable - not implemented
|
||||
RefToValue();
|
||||
RefToValue& operator=(const RefToValue&);
|
||||
|
||||
|
||||
T& ref_;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \ingroup ExceptionGroup
|
||||
/// \ingroup ExceptionGroup
|
||||
/// RefToValue creator.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -61,8 +73,8 @@ namespace Loki
|
|||
inline RefToValue<T> ByRef(T& t)
|
||||
{
|
||||
return RefToValue<T>(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The Loki Library
|
||||
// Copyright (c) 2006 Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_REGISTER_INC_
|
||||
#define LOKI_REGISTER_INC_
|
||||
|
|
|
@ -4,16 +4,26 @@
|
|||
//
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The authors make no representations about the suitability of this software
|
||||
// for any purpose. It is provided "as is" without express or implied warranty.
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// This code DOES NOT accompany the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -29,8 +39,8 @@
|
|||
* It as been defined in a separate file because of the many introduced
|
||||
* dependencies (SmartPtr.h would depend on Functor.h and CachedFactory.h
|
||||
* would depend on SmartPtr.h). By defining another header you pay for those
|
||||
* extra dependencies only if you need it.
|
||||
*
|
||||
* extra dependencies only if you need it.
|
||||
*
|
||||
* This file defines FunctionStorage a new SmartPointer storage policy and
|
||||
* SmartPointer a new CachedFactory encapsulation policy.
|
||||
*/
|
||||
|
@ -45,7 +55,7 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \class FunctionStorage
|
||||
///
|
||||
/// \ingroup SmartPointerStorageGroup
|
||||
/// \ingroup SmartPointerStorageGroup
|
||||
/// \brief Implementation of the StoragePolicy used by SmartPtr.
|
||||
///
|
||||
/// This storage policy is used by SmartPointer CachedFactory's encapsulation
|
||||
|
@ -76,7 +86,7 @@ namespace Loki
|
|||
FunctionStorage() : pointee_(Default()), functor_()
|
||||
{}
|
||||
|
||||
// The storage policy doesn't initialize the stored pointer
|
||||
// The storage policy doesn't initialize the stored pointer
|
||||
// which will be initialized by the OwnershipPolicy's Clone fn
|
||||
FunctionStorage(const FunctionStorage& rsh) : pointee_(0), functor_(rsh.functor_)
|
||||
{}
|
||||
|
@ -84,26 +94,26 @@ namespace Loki
|
|||
template <class U>
|
||||
FunctionStorage(const FunctionStorage<U>& rsh) : pointee_(0), functor_(rsh.functor_)
|
||||
{}
|
||||
|
||||
|
||||
FunctionStorage(const StoredType& p) : pointee_(p), functor_() {}
|
||||
|
||||
|
||||
PointerType operator->() const { return pointee_; }
|
||||
|
||||
|
||||
ReferenceType operator*() const { return *pointee_; }
|
||||
|
||||
|
||||
void Swap(FunctionStorage& rhs)
|
||||
{
|
||||
{
|
||||
std::swap(pointee_, rhs.pointee_);
|
||||
std::swap(functor_, rhs.functor_);
|
||||
}
|
||||
|
||||
|
||||
/// Sets the callback function to call. You have to specify it or
|
||||
/// the smartPtr will throw a bad_function_call exception.
|
||||
void SetCallBackFunction(const FunctorType &functor)
|
||||
{
|
||||
functor_ = functor;
|
||||
}
|
||||
|
||||
|
||||
// Accessors
|
||||
template <class F>
|
||||
friend typename FunctionStorage<F>::PointerType GetImpl(const FunctionStorage<F>& sp);
|
||||
|
@ -125,7 +135,7 @@ namespace Loki
|
|||
// Default value to initialize the pointer
|
||||
static StoredType Default()
|
||||
{ return 0; }
|
||||
|
||||
|
||||
private:
|
||||
// Data
|
||||
StoredType pointee_;
|
||||
|
@ -148,7 +158,7 @@ namespace Loki
|
|||
* \class SmartPointer
|
||||
* \ingroup EncapsulationPolicyCachedFactoryGroup
|
||||
* \brief Encapsulate the object in a SmartPtr with FunctionStorage policy.
|
||||
*
|
||||
*
|
||||
* The object will come back to the Cache as soon as no more SmartPtr are
|
||||
* referencing this object. You can customize the SmartPointer with the standard
|
||||
* SmartPtr policies (OwnershipPolicy, ConversionPolicy, CheckingPolicy,
|
||||
|
@ -160,31 +170,31 @@ namespace Loki
|
|||
template <class> class OwnershipPolicy = RefCounted,
|
||||
class ConversionPolicy = DisallowConversion,
|
||||
template <class> class CheckingPolicy = AssertCheck,
|
||||
template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
|
||||
>
|
||||
template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
|
||||
>
|
||||
class SmartPointer
|
||||
{
|
||||
private:
|
||||
typedef SmartPtr< AbstractProduct,OwnershipPolicy,
|
||||
ConversionPolicy, CheckingPolicy,
|
||||
FunctionStorage, ConstnessPolicy > CallBackSP;
|
||||
protected:
|
||||
protected:
|
||||
typedef CallBackSP ProductReturn;
|
||||
SmartPointer() : fun(this, &SmartPointer::smartPointerCallbackFunction) {}
|
||||
virtual ~SmartPointer(){}
|
||||
|
||||
|
||||
ProductReturn encapsulate(AbstractProduct* pProduct)
|
||||
{
|
||||
CallBackSP SP(pProduct);
|
||||
SP.SetCallBackFunction(fun);
|
||||
return SP;
|
||||
}
|
||||
|
||||
|
||||
AbstractProduct* release(ProductReturn &pProduct)
|
||||
{
|
||||
return GetImpl(pProduct);
|
||||
}
|
||||
|
||||
|
||||
const char* name(){return "smart pointer";}
|
||||
|
||||
private:
|
||||
|
|
|
@ -3,13 +3,25 @@
|
|||
// Copyright (c) 2009 by Fedor Pikus & Rich Sposato
|
||||
// The copyright on this file is protected under the terms of the MIT license.
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// The author makes no claims about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied warranty.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// $Id$
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2005 by Andrei Alexandrescu
|
||||
// Copyright (c) 2006 Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute, and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the suitability of this software
|
||||
// for any purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_SAFEFORMAT_INC_
|
||||
#define LOKI_SAFEFORMAT_INC_
|
||||
|
@ -16,8 +28,8 @@
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This file contains definitions for SafePrintf. SafeScanf coming soon (the
|
||||
// design is similar).
|
||||
// This file contains definitions for SafePrintf. SafeScanf coming soon (the
|
||||
// design is similar).
|
||||
// See Alexandrescu, Andrei: Type-safe Formatting, C/C++ Users Journal, Aug 2005
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -45,12 +57,12 @@
|
|||
#endif
|
||||
|
||||
// Windows headers could have min/max defined
|
||||
#ifdef max
|
||||
# undef max
|
||||
#endif
|
||||
#ifdef min
|
||||
# undef min
|
||||
#endif
|
||||
#ifdef max
|
||||
# undef max
|
||||
#endif
|
||||
#ifdef min
|
||||
# undef min
|
||||
#endif
|
||||
|
||||
namespace Loki
|
||||
{
|
||||
|
@ -74,7 +86,7 @@ namespace Loki
|
|||
assert(from <= to);
|
||||
if(from + s.second < to)
|
||||
throw std::overflow_error("");
|
||||
// s.first: position one past the final copied element
|
||||
// s.first: position one past the final copied element
|
||||
s.first = std::copy(from, to, s.first);
|
||||
// remaining buffer size
|
||||
s.second -= to - from;
|
||||
|
@ -88,7 +100,7 @@ namespace Loki
|
|||
|
||||
template <class Device, class Char>
|
||||
struct PrintfState {
|
||||
PrintfState(Device dev, const Char * format)
|
||||
PrintfState(Device dev, const Char * format)
|
||||
: device_(dev)
|
||||
, format_(format)
|
||||
, width_(0)
|
||||
|
@ -97,7 +109,7 @@ namespace Loki
|
|||
, result_(0) {
|
||||
Advance();
|
||||
}
|
||||
|
||||
|
||||
~PrintfState() {
|
||||
}
|
||||
|
||||
|
@ -125,7 +137,7 @@ namespace Loki
|
|||
PrintfState& operator()(LOKI_SAFEFORMAT_UNSIGNED_LONG i) {
|
||||
if (result_ == -1) return *this; // don't even bother
|
||||
// % [flags] [width] [.prec] [modifier] type_char
|
||||
// Fetch the flags
|
||||
// Fetch the flags
|
||||
ReadFlags();
|
||||
if (*format_ == '*') {
|
||||
// read the width and get out
|
||||
|
@ -163,7 +175,7 @@ namespace Loki
|
|||
PrintUsing_snprintf(n,"p");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
PrintfState& operator()(double n) {
|
||||
if (result_ == -1) return *this; // don't even bother
|
||||
PrintUsing_snprintf(n,"eEfgG");
|
||||
|
@ -180,17 +192,17 @@ namespace Loki
|
|||
PrintfState& operator()(int * pi) {
|
||||
return StoreCountHelper(pi);
|
||||
}
|
||||
|
||||
|
||||
// Store the number of characters printed so far
|
||||
PrintfState& operator()(short * pi) {
|
||||
return StoreCountHelper(pi);
|
||||
}
|
||||
|
||||
|
||||
// Store the number of characters printed so far
|
||||
PrintfState& operator()(long * pi) {
|
||||
return StoreCountHelper(pi);
|
||||
}
|
||||
|
||||
|
||||
PrintfState& operator()(const std::string& stdstr) {
|
||||
return operator()(stdstr.c_str());
|
||||
}
|
||||
|
@ -222,16 +234,16 @@ namespace Loki
|
|||
Next();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
PrintfState& operator()(const void *const p) {
|
||||
return (*this)(reinterpret_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(p));
|
||||
}
|
||||
|
||||
|
||||
// read the result
|
||||
operator int() const {
|
||||
return static_cast<int>(result_);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
PrintfState& operator=(const PrintfState&);
|
||||
template <typename T>
|
||||
|
@ -275,7 +287,7 @@ namespace Loki
|
|||
Char * bufLast = buf + (sizeof(buf) / sizeof(Char) - 1);
|
||||
Char signChar = 0;
|
||||
unsigned int base = 10;
|
||||
|
||||
|
||||
if (formatChar == 'c') {
|
||||
// Format only one character
|
||||
// The 'fill with zeros' flag is ignored
|
||||
|
@ -289,7 +301,7 @@ namespace Loki
|
|||
bufLast = isSigned
|
||||
? RenderWithoutSign(static_cast<LOKI_SAFEFORMAT_SIGNED_LONG>(i), bufLast, base,
|
||||
formatChar == 'X')
|
||||
: RenderWithoutSign(i, bufLast, base,
|
||||
: RenderWithoutSign(i, bufLast, base,
|
||||
formatChar == 'X');
|
||||
// Add the sign
|
||||
if (isSigned) {
|
||||
|
@ -299,12 +311,12 @@ namespace Loki
|
|||
: 0;
|
||||
}
|
||||
}
|
||||
// precision
|
||||
size_t
|
||||
// precision
|
||||
size_t
|
||||
countDigits = bufEnd - bufLast,
|
||||
countZeros = prec_ != size_t(-1) && countDigits < prec_ &&
|
||||
countZeros = prec_ != size_t(-1) && countDigits < prec_ &&
|
||||
formatChar != 'c'
|
||||
? prec_ - countDigits
|
||||
? prec_ - countDigits
|
||||
: 0,
|
||||
countBase = base != 10 && AlternateForm() && i != 0
|
||||
? (base == 16 ? 2 : countZeros > 0 ? 0 : 1)
|
||||
|
@ -337,7 +349,7 @@ namespace Loki
|
|||
// done, advance
|
||||
Next();
|
||||
}
|
||||
|
||||
|
||||
void Write(const Char* b, const Char* e) {
|
||||
if (result_ < 0) return;
|
||||
const LOKI_SAFEFORMAT_SIGNED_LONG x = e - b;
|
||||
|
@ -366,7 +378,7 @@ namespace Loki
|
|||
memcpy(fmtBuf, fmt, (format_ - fmt) * sizeof(Char));
|
||||
fmtBuf[format_ - fmt] = 0;
|
||||
|
||||
const int stored =
|
||||
const int stored =
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER < 1400
|
||||
_snprintf
|
||||
|
@ -374,10 +386,10 @@ namespace Loki
|
|||
_snprintf_s
|
||||
#endif
|
||||
#else
|
||||
snprintf
|
||||
#endif
|
||||
snprintf
|
||||
#endif
|
||||
(resultBuf, sizeof(resultBuf) / sizeof(Char), fmtBuf, n);
|
||||
|
||||
|
||||
if (stored < 0) {
|
||||
result_ = -1;
|
||||
return;
|
||||
|
@ -391,8 +403,8 @@ namespace Loki
|
|||
Write(&c, &c + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Char* RenderWithoutSign(LOKI_SAFEFORMAT_UNSIGNED_LONG n, char* bufLast,
|
||||
|
||||
Char* RenderWithoutSign(LOKI_SAFEFORMAT_UNSIGNED_LONG n, char* bufLast,
|
||||
unsigned int base, bool uppercase) {
|
||||
const Char hex1st = uppercase ? 'A' : 'a';
|
||||
for (;;) {
|
||||
|
@ -407,11 +419,11 @@ namespace Loki
|
|||
return bufLast;
|
||||
}
|
||||
|
||||
char* RenderWithoutSign(LOKI_SAFEFORMAT_SIGNED_LONG n, char* bufLast, unsigned int base,
|
||||
char* RenderWithoutSign(LOKI_SAFEFORMAT_SIGNED_LONG n, char* bufLast, unsigned int base,
|
||||
bool uppercase) {
|
||||
if (n != LONG_MIN) {
|
||||
return RenderWithoutSign(static_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(n < 0 ? -n : n),
|
||||
bufLast, base, uppercase);
|
||||
bufLast, base, uppercase);
|
||||
}
|
||||
// annoying corner case
|
||||
char* save = bufLast;
|
||||
|
@ -421,17 +433,17 @@ namespace Loki
|
|||
--(*save);
|
||||
return bufLast;
|
||||
}
|
||||
|
||||
|
||||
void Next() {
|
||||
++format_;
|
||||
Advance();
|
||||
}
|
||||
|
||||
|
||||
void Advance() {
|
||||
ResetAll();
|
||||
const Char* begin = format_;
|
||||
for (;;) {
|
||||
if (*format_ == '%') {
|
||||
if (*format_ == '%') {
|
||||
if (format_[1] != '%') { // It's a format specifier
|
||||
Write(begin, format_);
|
||||
++format_;
|
||||
|
@ -440,7 +452,7 @@ namespace Loki
|
|||
// It's a "%%"
|
||||
Write(begin, ++format_);
|
||||
begin = ++format_;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
if (*format_ == 0) {
|
||||
Write(begin, format_);
|
||||
|
@ -449,7 +461,7 @@ namespace Loki
|
|||
++format_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ReadFlags() {
|
||||
for (;; ++format_) {
|
||||
switch (*format_) {
|
||||
|
@ -462,7 +474,7 @@ namespace Loki
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ParseDecimalSizeT(size_t& dest) {
|
||||
if (!std::isdigit(*format_, std::locale())) return;
|
||||
size_t r = 0;
|
||||
|
@ -474,17 +486,17 @@ namespace Loki
|
|||
} while (std::isdigit(*format_, std::locale()));
|
||||
dest = r;
|
||||
}
|
||||
|
||||
|
||||
void ReadWidth() {
|
||||
ParseDecimalSizeT(width_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ReadPrecision() {
|
||||
assert(*format_ == '.');
|
||||
++format_;
|
||||
ParseDecimalSizeT(prec_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ReadModifiers() {
|
||||
switch (*format_) {
|
||||
case 'h': SetForceShort(); ++format_; break;
|
||||
|
@ -492,15 +504,15 @@ namespace Loki
|
|||
// more (C99 and platform-specific modifiers) to come
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ReadLeaders() {
|
||||
ReadFlags();
|
||||
ReadWidth();
|
||||
if (*format_ == '.') ReadPrecision();
|
||||
ReadModifiers();
|
||||
}
|
||||
|
||||
enum {
|
||||
|
||||
enum {
|
||||
leftJustify = 1,
|
||||
showSignAlways = 2,
|
||||
blank = 4,
|
||||
|
@ -508,7 +520,7 @@ namespace Loki
|
|||
fillZeros = 16,
|
||||
forceShort = 32
|
||||
};
|
||||
|
||||
|
||||
bool LeftJustify() const { return (flags_ & leftJustify) != 0; }
|
||||
bool ShowSignAlways() const { return (flags_ & showSignAlways) != 0; }
|
||||
void SetWidth(size_t w) { width_ = w; }
|
||||
|
@ -525,7 +537,7 @@ namespace Loki
|
|||
void SetFillZeros() { flags_ |= fillZeros; }
|
||||
void ResetFillZeros() { flags_ &= ~fillZeros; }
|
||||
void SetForceShort() { flags_ |= forceShort; }
|
||||
|
||||
|
||||
void ResetAll() {
|
||||
assert(result_ != EOF);
|
||||
width_ = 0;
|
||||
|
@ -577,7 +589,7 @@ namespace Loki
|
|||
}
|
||||
|
||||
template <class Char, std::size_t N>
|
||||
PrintfState<std::pair<Char*, std::size_t>, Char>
|
||||
PrintfState<std::pair<Char*, std::size_t>, Char>
|
||||
BufPrintf(Char (&buf)[N], const Char* format) {
|
||||
std::pair<Char*, std::size_t> temp(buf, N);
|
||||
return PrintfState<std::pair<Char*, std::size_t>, Char>(temp, format);
|
||||
|
|
|
@ -3,14 +3,25 @@
|
|||
// Copyright (c) 2000 Andrei Alexandrescu
|
||||
// Copyright (c) 2000 Petru Marginean
|
||||
// Copyright (c) 2005 Joshua Lehrer
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_SCOPEGUARD_INC_
|
||||
#define LOKI_SCOPEGUARD_INC_
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The Loki Library
|
||||
// Copyright (c) 2005 by Peter Kümmel
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_SEQUENCE_INC_
|
||||
#define LOKI_SEQUENCE_INC_
|
||||
|
@ -31,12 +43,12 @@ namespace Loki
|
|||
{
|
||||
private:
|
||||
typedef typename Seq< T02, T03, T04, T05, T06, T07, T08, T09, T10,
|
||||
T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>::Type
|
||||
T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>::Type
|
||||
TailResult;
|
||||
public:
|
||||
typedef Typelist<T01, TailResult> Type;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct Seq<>
|
||||
{
|
||||
|
|
|
@ -4,13 +4,25 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_SINGLETON_INC_
|
||||
#define LOKI_SINGLETON_INC_
|
||||
|
|
|
@ -2,15 +2,25 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_SMALLOBJ_INC_
|
||||
#define LOKI_SMALLOBJ_INC_
|
||||
|
@ -57,7 +67,7 @@ namespace Loki
|
|||
{
|
||||
/** @struct DieAsSmallObjectParent
|
||||
@ingroup SmallObjectGroup
|
||||
Lifetime policy to manage lifetime dependencies of
|
||||
Lifetime policy to manage lifetime dependencies of
|
||||
SmallObject base and child classes.
|
||||
The Base class should have this lifetime
|
||||
*/
|
||||
|
@ -66,14 +76,14 @@ namespace Loki
|
|||
|
||||
/** @struct DieAsSmallObjectChild
|
||||
@ingroup SmallObjectGroup
|
||||
Lifetime policy to manage lifetime dependencies of
|
||||
Lifetime policy to manage lifetime dependencies of
|
||||
SmallObject base and child classes.
|
||||
The Child class should have this lifetime
|
||||
*/
|
||||
template <class T>
|
||||
struct DieAsSmallObjectChild : DieDirectlyBeforeLast<T> {};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace Private
|
||||
{
|
||||
|
@ -108,7 +118,7 @@ namespace Loki
|
|||
public:
|
||||
/** Allocates a block of memory of requested size. Complexity is often
|
||||
constant-time, but might be O(C) where C is the number of Chunks in a
|
||||
FixedAllocator.
|
||||
FixedAllocator.
|
||||
|
||||
@par Exception Safety Level
|
||||
Provides either strong-exception safety, or no-throw exception-safety
|
||||
|
@ -201,7 +211,7 @@ namespace Loki
|
|||
This template class is derived from
|
||||
SmallObjAllocator in order to pass template arguments into it, and still
|
||||
have a default constructor for the singleton. Each instance is a unique
|
||||
combination of all the template parameters, and hence is singleton only
|
||||
combination of all the template parameters, and hence is singleton only
|
||||
with respect to those parameters. The template parameters have default
|
||||
values and the class has typedefs identical to both SmallObject and
|
||||
SmallValueObject so that this class can be used directly instead of going
|
||||
|
@ -342,9 +352,9 @@ namespace Loki
|
|||
@ingroup SmallObjectGroup
|
||||
Base class for small object allocation classes.
|
||||
The shared implementation of the new and delete operators are here instead
|
||||
of being duplicated in both SmallObject or SmallValueObject, later just
|
||||
called Small-Objects. This class is not meant to be used directly by clients,
|
||||
or derived from by clients. Class has no data members so compilers can
|
||||
of being duplicated in both SmallObject or SmallValueObject, later just
|
||||
called Small-Objects. This class is not meant to be used directly by clients,
|
||||
or derived from by clients. Class has no data members so compilers can
|
||||
use Empty-Base-Optimization.
|
||||
|
||||
@par ThreadingModel
|
||||
|
@ -359,24 +369,24 @@ namespace Loki
|
|||
a thread-safe allocator, use the ClassLevelLockable policy.
|
||||
|
||||
@par Lifetime Policy
|
||||
|
||||
|
||||
The SmallObjectBase template needs a lifetime policy because it owns
|
||||
a singleton of SmallObjAllocator which does all the low level functions.
|
||||
a singleton of SmallObjAllocator which does all the low level functions.
|
||||
When using a Small-Object in combination with the SingletonHolder template
|
||||
you have to choose two lifetimes, that of the Small-Object and that of
|
||||
the singleton. The rule is: The Small-Object lifetime must be greater than
|
||||
the lifetime of the singleton hosting the Small-Object. Violating this rule
|
||||
results in a crash on exit, because the hosting singleton tries to delete
|
||||
the Small-Object which is then already destroyed.
|
||||
|
||||
The lifetime policies recommended for use with Small-Objects hosted
|
||||
by a SingletonHolder template are
|
||||
the Small-Object which is then already destroyed.
|
||||
|
||||
The lifetime policies recommended for use with Small-Objects hosted
|
||||
by a SingletonHolder template are
|
||||
- LongevityLifetime::DieAsSmallObjectParent / LongevityLifetime::DieAsSmallObjectChild
|
||||
- SingletonWithLongevity
|
||||
- FollowIntoDeath (not supported by MSVC 7.1)
|
||||
- NoDestroy
|
||||
|
||||
The default lifetime of Small-Objects is
|
||||
|
||||
The default lifetime of Small-Objects is
|
||||
LongevityLifetime::DieAsSmallObjectParent to
|
||||
insure that memory is not released before a object with the lifetime
|
||||
LongevityLifetime::DieAsSmallObjectChild using that
|
||||
|
@ -384,45 +394,45 @@ namespace Loki
|
|||
lifetime has the highest possible value of a SetLongevity lifetime, so
|
||||
you can use it in combination with your own lifetime not having also
|
||||
the highest possible value.
|
||||
|
||||
The DefaultLifetime and PhoenixSingleton policies are *not* recommended
|
||||
since they can cause the allocator to be destroyed and release memory
|
||||
|
||||
The DefaultLifetime and PhoenixSingleton policies are *not* recommended
|
||||
since they can cause the allocator to be destroyed and release memory
|
||||
for singletons hosting a object which inherit from either SmallObject
|
||||
or SmallValueObject.
|
||||
|
||||
or SmallValueObject.
|
||||
|
||||
@par Lifetime usage
|
||||
|
||||
- LongevityLifetime: The Small-Object has
|
||||
|
||||
- LongevityLifetime: The Small-Object has
|
||||
LongevityLifetime::DieAsSmallObjectParent policy and the Singleton
|
||||
hosting the Small-Object has LongevityLifetime::DieAsSmallObjectChild.
|
||||
The child lifetime has a hard coded SetLongevity lifetime which is
|
||||
shorter than the lifetime of the parent, thus the child dies
|
||||
hosting the Small-Object has LongevityLifetime::DieAsSmallObjectChild.
|
||||
The child lifetime has a hard coded SetLongevity lifetime which is
|
||||
shorter than the lifetime of the parent, thus the child dies
|
||||
before the parent.
|
||||
|
||||
|
||||
- Both Small-Object and Singleton use SingletonWithLongevity policy.
|
||||
The longevity level for the singleton must be lower than that for the
|
||||
Small-Object. This is why the AllocatorSingleton's GetLongevity function
|
||||
Small-Object. This is why the AllocatorSingleton's GetLongevity function
|
||||
returns the highest value.
|
||||
|
||||
- FollowIntoDeath lifetime: The Small-Object has
|
||||
|
||||
- FollowIntoDeath lifetime: The Small-Object has
|
||||
FollowIntoDeath::With<LIFETIME>::AsMasterLiftime
|
||||
policy and the Singleton has
|
||||
policy and the Singleton has
|
||||
FollowIntoDeath::AfterMaster<MASTERSINGLETON>::IsDestroyed policy,
|
||||
where you could choose the LIFETIME.
|
||||
|
||||
- Both Small-Object and Singleton use NoDestroy policy.
|
||||
where you could choose the LIFETIME.
|
||||
|
||||
- Both Small-Object and Singleton use NoDestroy policy.
|
||||
Since neither is ever destroyed, the destruction order does not matter.
|
||||
Note: you will get memory leaks!
|
||||
|
||||
|
||||
- The Small-Object has NoDestroy policy but the Singleton has
|
||||
SingletonWithLongevity policy. Note: you will get memory leaks!
|
||||
|
||||
|
||||
|
||||
|
||||
You should *not* use NoDestroy for the singleton, and then use
|
||||
SingletonWithLongevity for the Small-Object.
|
||||
|
||||
SingletonWithLongevity for the Small-Object.
|
||||
|
||||
@par Examples:
|
||||
|
||||
|
||||
- test/SmallObj/SmallSingleton.cpp
|
||||
- test/Singleton/Dependencies.cpp
|
||||
*/
|
||||
|
@ -440,12 +450,12 @@ namespace Loki
|
|||
|
||||
#if (LOKI_MAX_SMALL_OBJECT_SIZE != 0) && (LOKI_DEFAULT_CHUNK_SIZE != 0) && (LOKI_DEFAULT_OBJECT_ALIGNMENT != 0)
|
||||
|
||||
public:
|
||||
/// Defines type of allocator singleton, must be public
|
||||
public:
|
||||
/// Defines type of allocator singleton, must be public
|
||||
/// to handle singleton lifetime dependencies.
|
||||
typedef AllocatorSingleton< ThreadingModel, chunkSize,
|
||||
maxSmallObjectSize, objectAlignSize, LifetimePolicy > ObjAllocatorSingleton;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/// Defines type for thread-safety locking mechanism.
|
||||
|
@ -453,7 +463,7 @@ namespace Loki
|
|||
|
||||
/// Use singleton defined in AllocatorSingleton.
|
||||
typedef typename ObjAllocatorSingleton::MyAllocatorSingleton MyAllocatorSingleton;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/// Throwing single-object new throws bad_alloc when allocation fails.
|
||||
|
|
|
@ -4,13 +4,25 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_SMARTPTR_INC_
|
||||
#define LOKI_SMARTPTR_INC_
|
||||
|
|
|
@ -1,15 +1,25 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The Loki Library
|
||||
// Copyright (c) 2006 Rich Sposato
|
||||
// The copyright on this file is protected under the terms of the MIT license.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_STRONG_PTR_INC_
|
||||
#define LOKI_STRONG_PTR_INC_
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The Loki Library
|
||||
// Copyright (c) 2009 by Rich Sposato
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author makes no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LOKI_THREAD_LOCAL_H_INCLUDED
|
||||
|
|
|
@ -4,13 +4,25 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_THREADS_INC_
|
||||
#define LOKI_THREADS_INC_
|
||||
|
|
|
@ -2,15 +2,27 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Last update: June 20, 2001
|
||||
|
@ -18,5 +30,5 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This file is intentionally left empty
|
||||
// Due to compiler limitations, its contents has been moved to
|
||||
// HierarchyGenerators.h
|
||||
// HierarchyGenerators.h
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -2,15 +2,27 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Welsey Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_TYPEMANIP_INC_
|
||||
#define LOKI_TYPEMANIP_INC_
|
||||
|
@ -32,7 +44,7 @@ namespace Loki
|
|||
{
|
||||
enum { value = v };
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template Type2Type
|
||||
// Converts each type into a unique, insipid type
|
||||
|
@ -45,7 +57,7 @@ namespace Loki
|
|||
{
|
||||
typedef T OriginalType;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template Select
|
||||
// Selects one of two types based upon a boolean constant
|
||||
|
@ -66,7 +78,7 @@ namespace Loki
|
|||
{
|
||||
typedef U Result;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template IsSameType
|
||||
// Return true iff two given types are the same
|
||||
|
@ -81,7 +93,7 @@ namespace Loki
|
|||
{
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct IsSameType<T,T>
|
||||
{
|
||||
|
@ -133,27 +145,27 @@ namespace Loki
|
|||
enum { exists2Way = exists && Conversion<U, T>::exists };
|
||||
enum { sameType = false };
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
struct Conversion<T, T>
|
||||
struct Conversion<T, T>
|
||||
{
|
||||
enum { exists = 1, exists2Way = 1, sameType = 1 };
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
struct Conversion<void, T>
|
||||
struct Conversion<void, T>
|
||||
{
|
||||
enum { exists = 0, exists2Way = 0, sameType = 0 };
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
struct Conversion<T, void>
|
||||
struct Conversion<T, void>
|
||||
{
|
||||
enum { exists = 0, exists2Way = 0, sameType = 0 };
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct Conversion<void, void>
|
||||
struct Conversion<void, void>
|
||||
{
|
||||
public:
|
||||
enum { exists = 1, exists2Way = 1, sameType = 1 };
|
||||
|
@ -161,8 +173,8 @@ namespace Loki
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template SuperSubclass
|
||||
// Invocation: SuperSubclass<B, D>::value where B and D are types.
|
||||
// Returns true if B is a public base of D, or if B and D are aliases of the
|
||||
// Invocation: SuperSubclass<B, D>::value where B and D are types.
|
||||
// Returns true if B is a public base of D, or if B and D are aliases of the
|
||||
// same type.
|
||||
//
|
||||
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||
|
@ -173,40 +185,40 @@ struct SuperSubclass
|
|||
{
|
||||
enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
|
||||
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
|
||||
|
||||
|
||||
// Dummy enum to make sure that both classes are fully defined.
|
||||
enum{ dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) };
|
||||
};
|
||||
|
||||
template <>
|
||||
struct SuperSubclass<void, void>
|
||||
struct SuperSubclass<void, void>
|
||||
{
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
template <class U>
|
||||
struct SuperSubclass<void, U>
|
||||
struct SuperSubclass<void, U>
|
||||
{
|
||||
enum { value = (::Loki::Conversion<const volatile U*, const volatile void*>::exists &&
|
||||
!::Loki::Conversion<const volatile void*, const volatile void*>::sameType) };
|
||||
|
||||
|
||||
// Dummy enum to make sure that both classes are fully defined.
|
||||
enum{ dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) };
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct SuperSubclass<T, void>
|
||||
struct SuperSubclass<T, void>
|
||||
{
|
||||
enum { value = (::Loki::Conversion<const volatile void*, const volatile T*>::exists &&
|
||||
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
|
||||
|
||||
|
||||
// Dummy enum to make sure that both classes are fully defined.
|
||||
enum{ dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) };
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template SuperSubclassStrict
|
||||
// Invocation: SuperSubclassStrict<B, D>::value where B and D are types.
|
||||
// Invocation: SuperSubclassStrict<B, D>::value where B and D are types.
|
||||
// Returns true if B is a public base of D.
|
||||
//
|
||||
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||
|
@ -218,35 +230,35 @@ struct SuperSubclassStrict
|
|||
enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
|
||||
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
|
||||
!::Loki::Conversion<const volatile T*, const volatile U*>::sameType) };
|
||||
|
||||
|
||||
// Dummy enum to make sure that both classes are fully defined.
|
||||
enum{ dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) };
|
||||
};
|
||||
|
||||
template<>
|
||||
struct SuperSubclassStrict<void, void>
|
||||
struct SuperSubclassStrict<void, void>
|
||||
{
|
||||
enum { value = false };
|
||||
};
|
||||
|
||||
template<class U>
|
||||
struct SuperSubclassStrict<void, U>
|
||||
struct SuperSubclassStrict<void, U>
|
||||
{
|
||||
enum { value = (::Loki::Conversion<const volatile U*, const volatile void*>::exists &&
|
||||
!::Loki::Conversion<const volatile void*, const volatile void*>::sameType &&
|
||||
!::Loki::Conversion<const volatile void*, const volatile U*>::sameType) };
|
||||
|
||||
|
||||
// Dummy enum to make sure that both classes are fully defined.
|
||||
enum{ dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) };
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct SuperSubclassStrict<T, void>
|
||||
struct SuperSubclassStrict<T, void>
|
||||
{
|
||||
enum { value = (::Loki::Conversion<const volatile void*, const volatile T*>::exists &&
|
||||
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
|
||||
!::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
|
||||
|
||||
|
||||
// Dummy enum to make sure that both classes are fully defined.
|
||||
enum{ dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) };
|
||||
};
|
||||
|
@ -256,8 +268,8 @@ struct SuperSubclassStrict<T, void>
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// macro SUPERSUBCLASS
|
||||
// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
|
||||
// Returns true if B is a public base of D, or if B and D are aliases of the
|
||||
// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
|
||||
// Returns true if B is a public base of D, or if B and D are aliases of the
|
||||
// same type.
|
||||
//
|
||||
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||
|
@ -269,7 +281,7 @@ struct SuperSubclassStrict<T, void>
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// macro SUPERSUBCLASS_STRICT
|
||||
// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
|
||||
// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
|
||||
// Returns true if B is a public base of D.
|
||||
//
|
||||
// Caveat: might not work if T and U are in a private inheritance hierarchy.
|
||||
|
|
|
@ -4,13 +4,25 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_TYPETRAITS_INC_
|
||||
#define LOKI_TYPETRAITS_INC_
|
||||
|
|
|
@ -2,15 +2,27 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Welsey Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_TYPELIST_INC_
|
||||
#define LOKI_TYPELIST_INC_
|
||||
|
@ -62,17 +74,17 @@ namespace Loki
|
|||
typename T10 = NullType, typename T11 = NullType, typename T12 = NullType,
|
||||
typename T13 = NullType, typename T14 = NullType, typename T15 = NullType,
|
||||
typename T16 = NullType, typename T17 = NullType, typename T18 = NullType
|
||||
>
|
||||
>
|
||||
struct MakeTypelist
|
||||
{
|
||||
private:
|
||||
typedef typename MakeTypelist
|
||||
<
|
||||
T2 , T3 , T4 ,
|
||||
T5 , T6 , T7 ,
|
||||
T8 , T9 , T10,
|
||||
T2 , T3 , T4 ,
|
||||
T5 , T6 , T7 ,
|
||||
T8 , T9 , T10,
|
||||
T11, T12, T13,
|
||||
T14, T15, T16,
|
||||
T14, T15, T16,
|
||||
T17, T18
|
||||
>
|
||||
::Result TailResult;
|
||||
|
@ -101,7 +113,7 @@ namespace Loki
|
|||
{
|
||||
enum { value = 0 };
|
||||
};
|
||||
|
||||
|
||||
template <class T, class U>
|
||||
struct Length< Typelist<T, U> >
|
||||
{
|
||||
|
@ -111,7 +123,7 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template TypeAt
|
||||
// Finds the type at a given index in a typelist
|
||||
// Invocation (TList is a typelist and index is a compile-time integral
|
||||
// Invocation (TList is a typelist and index is a compile-time integral
|
||||
// constant):
|
||||
// TypeAt<TList, index>::Result
|
||||
// returns the type in position 'index' in TList
|
||||
|
@ -119,7 +131,7 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList, unsigned int index> struct TypeAt;
|
||||
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct TypeAt<Typelist<Head, Tail>, 0>
|
||||
{
|
||||
|
@ -135,10 +147,10 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template TypeAtNonStrict
|
||||
// Finds the type at a given index in a typelist
|
||||
// Invocations (TList is a typelist and index is a compile-time integral
|
||||
// Invocations (TList is a typelist and index is a compile-time integral
|
||||
// constant):
|
||||
// a) TypeAt<TList, index>::Result
|
||||
// returns the type in position 'index' in TList, or NullType if index is
|
||||
// returns the type in position 'index' in TList, or NullType if index is
|
||||
// out-of-bounds
|
||||
// b) TypeAt<TList, index, D>::Result
|
||||
// returns the type in position 'index' in TList, or D if index is out-of-bounds
|
||||
|
@ -150,17 +162,17 @@ namespace Loki
|
|||
{
|
||||
typedef DefaultType Result;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, typename DefaultType>
|
||||
struct TypeAtNonStrict<Typelist<Head, Tail>, 0, DefaultType>
|
||||
{
|
||||
typedef Head Result;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, unsigned int i, typename DefaultType>
|
||||
struct TypeAtNonStrict<Typelist<Head, Tail>, i, DefaultType>
|
||||
{
|
||||
typedef typename
|
||||
typedef typename
|
||||
TypeAtNonStrict<Tail, i - 1, DefaultType>::Result Result;
|
||||
};
|
||||
|
||||
|
@ -173,19 +185,19 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList, class T> struct IndexOf;
|
||||
|
||||
|
||||
template <class T>
|
||||
struct IndexOf<NullType, T>
|
||||
{
|
||||
enum { value = -1 };
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Tail>
|
||||
struct IndexOf<Typelist<T, Tail>, T>
|
||||
{
|
||||
enum { value = 0 };
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, class T>
|
||||
struct IndexOf<Typelist<Head, Tail>, T>
|
||||
{
|
||||
|
@ -204,12 +216,12 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList, class T> struct Append;
|
||||
|
||||
|
||||
template <> struct Append<NullType, NullType>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
|
||||
template <class T> struct Append<NullType, T>
|
||||
{
|
||||
typedef Typelist<T,NullType> Result;
|
||||
|
@ -220,15 +232,15 @@ namespace Loki
|
|||
{
|
||||
typedef Typelist<Head, Tail> Result;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, class T>
|
||||
struct Append<Typelist<Head, Tail>, T>
|
||||
{
|
||||
typedef Typelist<Head,
|
||||
typedef Typelist<Head,
|
||||
typename Append<Tail, T>::Result>
|
||||
Result;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// class template Erase
|
||||
// Erases the first occurence, if any, of a type in a typelist
|
||||
|
@ -238,7 +250,7 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList, class T> struct Erase;
|
||||
|
||||
|
||||
template <class T> // Specialization 1
|
||||
struct Erase<NullType, T>
|
||||
{
|
||||
|
@ -254,7 +266,7 @@ namespace Loki
|
|||
template <class Head, class Tail, class T> // Specialization 3
|
||||
struct Erase<Typelist<Head, Tail>, T>
|
||||
{
|
||||
typedef Typelist<Head,
|
||||
typedef Typelist<Head,
|
||||
typename Erase<Tail, T>::Result>
|
||||
Result;
|
||||
};
|
||||
|
@ -283,7 +295,7 @@ namespace Loki
|
|||
struct EraseAll<Typelist<Head, Tail>, T>
|
||||
{
|
||||
// Go all the way down the list removing the type
|
||||
typedef Typelist<Head,
|
||||
typedef Typelist<Head,
|
||||
typename EraseAll<Tail, T>::Result>
|
||||
Result;
|
||||
};
|
||||
|
@ -296,7 +308,7 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList> struct NoDuplicates;
|
||||
|
||||
|
||||
template <> struct NoDuplicates<NullType>
|
||||
{
|
||||
typedef NullType Result;
|
||||
|
@ -321,7 +333,7 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList, class T, class U> struct Replace;
|
||||
|
||||
|
||||
template <class T, class U>
|
||||
struct Replace<NullType, T, U>
|
||||
{
|
||||
|
@ -351,19 +363,19 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList, class T, class U> struct ReplaceAll;
|
||||
|
||||
|
||||
template <class T, class U>
|
||||
struct ReplaceAll<NullType, T, U>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Tail, class U>
|
||||
struct ReplaceAll<Typelist<T, Tail>, T, U>
|
||||
{
|
||||
typedef Typelist<U, typename ReplaceAll<Tail, T, U>::Result> Result;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, class T, class U>
|
||||
struct ReplaceAll<Typelist<Head, Tail>, T, U>
|
||||
{
|
||||
|
@ -381,13 +393,13 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList> struct Reverse;
|
||||
|
||||
|
||||
template <>
|
||||
struct Reverse<NullType>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct Reverse< Typelist<Head, Tail> >
|
||||
{
|
||||
|
@ -404,13 +416,13 @@ namespace Loki
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList, class T> struct MostDerived;
|
||||
|
||||
|
||||
template <class T>
|
||||
struct MostDerived<NullType, T>
|
||||
{
|
||||
typedef T Result;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, class T>
|
||||
struct MostDerived<Typelist<Head, Tail>, T>
|
||||
{
|
||||
|
@ -427,17 +439,17 @@ namespace Loki
|
|||
// Arranges the types in a typelist so that the most derived types appear first
|
||||
// Invocation (TList is a typelist):
|
||||
// DerivedToFront<TList>::Result
|
||||
// returns the reordered TList
|
||||
// returns the reordered TList
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class TList> struct DerivedToFront;
|
||||
|
||||
|
||||
template <>
|
||||
struct DerivedToFront<NullType>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct DerivedToFront< Typelist<Head, Tail> >
|
||||
{
|
||||
|
@ -450,7 +462,7 @@ namespace Loki
|
|||
public:
|
||||
typedef Typelist<TheMostDerived, L> Result;
|
||||
};
|
||||
|
||||
|
||||
} // namespace TL
|
||||
} // namespace Loki
|
||||
|
||||
|
|
|
@ -2,15 +2,27 @@
|
|||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Welsey Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_TYPELISTMACROS_INC_
|
||||
#define LOKI_TYPELISTMACROS_INC_
|
||||
|
@ -24,7 +36,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// macros LOKI_TYPELIST_1, LOKI_TYPELIST_2, ... LOKI_TYPELIST_50
|
||||
// Each takes a number of arguments equal to its numeric suffix
|
||||
// The arguments are type names. LOKI_TYPELIST_NN generates a typelist containing
|
||||
// The arguments are type names. LOKI_TYPELIST_NN generates a typelist containing
|
||||
// all types passed as arguments, in that order.
|
||||
// Example: LOKI_TYPELIST_2(char, int) generates a type containing char and int.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -4,13 +4,25 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_VISITOR_INC_
|
||||
#define LOKI_VISITOR_INC_
|
||||
|
|
|
@ -4,13 +4,25 @@
|
|||
// This code accompanies the book:
|
||||
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
|
||||
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
|
||||
// Permission to use, copy, modify, distribute and sell this software for any
|
||||
// purpose is hereby granted without fee, provided that the above copyright
|
||||
// notice appear in all copies and that both that copyright notice and this
|
||||
// permission notice appear in supporting documentation.
|
||||
// The author or Addison-Wesley Longman make no representations about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
// Code covered by the MIT License
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef LOKI_STATIC_CHECK_INC_
|
||||
#define LOKI_STATIC_CHECK_INC_
|
||||
|
|
Loading…
Add table
Reference in a new issue