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