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