Commit 3fa320a8 authored by Jan Travnicek's avatar Jan Travnicek Committed by Ing. Jan Trávníček

remove allocator fix

parent 192401a7
/*
* allocFix.hpp
*
* This file is part of Algorithms library toolkit.
* Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
* Algorithms library toolkit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Algorithms library toolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
*
* Created on: Mar 6, 2018
* Author: Jan Travnicek
*/
#ifndef __ALLOC_FIX_HPP_
#define __ALLOC_FIX_HPP_
// related to issue with 'undefined reference to allocator < ... >::allocator ( )', subject of a delete when g++ fixes the issue
// the undefined reference occurs when one inherits from a class whose constructor has default value for the allocator
// I guess the default parameter construction (allocator constructor) should be inlined but it isn't. Its code is not emited either.
namespace ext {
/**
* \brief
* Class implementing the fix of undefined allocator
*
* TODO test if later versions of g++ are no longer affected.
*/
template < class Alloc >
class AllocFix {
public:
/**
* \brief
* Constructor to make sure the default constructor of given Allocator exists.
*/
AllocFix ( ) {
// just to make sure the allocator constructor exists
static Alloc alloc;
(void) alloc; // make unused variable warning go away
}
};
} /* namespace ext */
#endif /* __ALLOC_FIX_HPP_ */
......@@ -30,7 +30,6 @@
#include <string>
#include <extensions/compare.hpp>
#include <extensions/allocFix.hpp>
#include <extensions/range.hpp>
namespace ext {
......@@ -45,7 +44,7 @@ namespace ext {
* \tparam Alloc the allocator of values of type T
*/
template < class T, class Alloc = std::allocator < T > >
class deque : public std::deque < T, Alloc >, AllocFix < Alloc > {
class deque : public std::deque < T, Alloc > {
public:
/**
* Inherit constructors of the standard deque
......
......@@ -30,7 +30,6 @@
#include <string>
#include <extensions/compare.hpp>
#include <extensions/allocFix.hpp>
#include <extensions/range.hpp>
namespace ext {
......
......@@ -30,7 +30,6 @@
#include <string>
#include <extensions/compare.hpp>
#include <extensions/allocFix.hpp>
#include <extensions/range.hpp>
namespace ext {
......@@ -45,7 +44,7 @@ namespace ext {
* \tparam Alloc the allocator of values of type T
*/
template < class T, class Alloc = std::allocator < T > >
class list : public std::list < T, Alloc >, AllocFix < Alloc > {
class list : public std::list < T, Alloc > {
public:
/**
* Inherit constructors of the standard list
......
......@@ -33,7 +33,6 @@
#include "pair.hpp"
#include <extensions/compare.hpp>
#include <extensions/allocFix.hpp>
#include <extensions/range.hpp>
namespace ext {
......@@ -50,7 +49,7 @@ namespace ext {
* \tparam Alloc the allocator of values of type T
*/
template < typename T, typename R, typename Cmp = std::less < >, typename Alloc = std::allocator < std::pair < const T, R > > >
class map : public std::map < T, R, Cmp, Alloc >, AllocFix < Alloc > {
class map : public std::map < T, R, Cmp, Alloc > {
public:
/**
* Inherit constructors of the standard map
......
......@@ -33,7 +33,6 @@
#include "pair.hpp"
#include <extensions/compare.hpp>
#include <extensions/allocFix.hpp>
#include <extensions/range.hpp>
namespace ext {
......@@ -50,7 +49,7 @@ namespace ext {
* \tparam Alloc the allocator of values of type T
*/
template < typename T, typename R, typename Cmp = std::less < >, typename Alloc = std::allocator < std::pair < const T, R > > >
class multimap : public std::multimap < T, R, Cmp, Alloc >, AllocFix < Alloc > {
class multimap : public std::multimap < T, R, Cmp, Alloc > {
public:
/**
* Inherit constructors of the standard multimap
......
......@@ -29,7 +29,6 @@
#include <string>
#include <extensions/compare.hpp>
#include <extensions/allocFix.hpp>
#include <extensions/range.hpp>
#include <extensions/clone.hpp>
#include <extensions/container/vector.hpp>
......
......@@ -30,7 +30,6 @@
#include <string>
#include <extensions/compare.hpp>
#include <extensions/allocFix.hpp>
#include <extensions/range.hpp>
namespace ext {
......@@ -45,7 +44,7 @@ namespace ext {
* \tparam Alloc the allocator of values of type T
*/
template < typename T, typename Cmp = std::less < >, typename Alloc = std::allocator < T > >
class set : public std::set < T, Cmp, Alloc >, AllocFix < Alloc > {
class set : public std::set < T, Cmp, Alloc > {
public:
/**
* Inherit constructors of the standard set
......
......@@ -30,7 +30,6 @@
#include <string>
#include <extensions/compare.hpp>
#include <extensions/allocFix.hpp>
#include <extensions/range.hpp>
namespace ext {
......@@ -48,7 +47,7 @@ namespace ext {
* \tparam Alloc the allocator of values of type T
*/
template < class T, class R, class Hash = std::hash < T >, class KeyEqual = std::equal_to < T >, class Alloc = std::allocator < std::pair < const T, R > > >
class unordered_map : public std::unordered_map < T, R, Hash, KeyEqual, Alloc >, AllocFix < Alloc > {
class unordered_map : public std::unordered_map < T, R, Hash, KeyEqual, Alloc > {
public:
/**
* Inherit constructors of the standard unordered_map
......
......@@ -31,7 +31,6 @@
#include <iostream>
#include <extensions/compare.hpp>
#include <extensions/allocFix.hpp>
#include <extensions/range.hpp>
namespace ext {
......@@ -46,7 +45,7 @@ namespace ext {
* \tparam Alloc the allocator of values of type T
*/
template < class T, class Alloc = std::allocator < T > >
class vector : public std::vector < T, Alloc >, AllocFix < Alloc > {
class vector : public std::vector < T, Alloc > {
public:
/**
* Inherit constructors of the standard vector
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment