From 1a68f72305a52d00a6de42638436fb08e9a45768 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Wed, 9 Aug 2017 15:11:08 +0200
Subject: [PATCH] move bitset to ext namespace

---
 .../matching/BNDMMatcherConstruction.h        |  4 +-
 .../src/stringology/query/BNDMOccurrences.h   |  4 +-
 alib2common/src/container/ObjectsBitset.h     | 24 +++++-----
 .../src/indexes/stringology/BNDMMatcher.h     | 24 +++++-----
 alib2std/src/extensions/bitset.hpp            | 46 +++++++++++++++----
 5 files changed, 65 insertions(+), 37 deletions(-)

diff --git a/alib2algo/src/stringology/matching/BNDMMatcherConstruction.h b/alib2algo/src/stringology/matching/BNDMMatcherConstruction.h
index 9ada90fcdb..223f21234c 100644
--- a/alib2algo/src/stringology/matching/BNDMMatcherConstruction.h
+++ b/alib2algo/src/stringology/matching/BNDMMatcherConstruction.h
@@ -41,9 +41,9 @@ template < class SymbolType, size_t BitmaskBitCount >
 indexes::stringology::BNDMMatcher < SymbolType, BitmaskBitCount > BNDMMatcherConstruction::construct ( const string::LinearString < SymbolType > & w ) {
 	size_t bitmaskLength = std::min ( w.getContent ( ).size ( ), BitmaskBitCount );
 
-	ext::map < SymbolType, std::bitset < BitmaskBitCount > > res;
+	ext::map < SymbolType, ext::bitset < BitmaskBitCount > > res;
 	for ( const SymbolType & symbol : w.getAlphabet ( ) )
-		res [ symbol ] = std::bitset < BitmaskBitCount > ( 0 );
+		res [ symbol ] = ext::bitset < BitmaskBitCount > ( 0 );
 
 	for ( unsigned i = 0; i < bitmaskLength; ++i )
 		res [ w.getContent ( ) [ i ] ] [ bitmaskLength - i - 1 ] = true;
diff --git a/alib2algo/src/stringology/query/BNDMOccurrences.h b/alib2algo/src/stringology/query/BNDMOccurrences.h
index 5f7de481eb..f9b872562e 100644
--- a/alib2algo/src/stringology/query/BNDMOccurrences.h
+++ b/alib2algo/src/stringology/query/BNDMOccurrences.h
@@ -51,7 +51,7 @@ ext::set < unsigned > BNDMOccurrences::query ( const indexes::stringology::BNDMM
 	size_t posInSubject = 0;
 	size_t bitmaskLength = std::min ( BitmaskBitCount, patternLength );
 
-	std::bitset < BitmaskBitCount > currentBitmask;
+	ext::bitset < BitmaskBitCount > currentBitmask;
 
 	while ( posInSubject <= subjectLength - patternLength ) {
 		size_t posInPattern = bitmaskLength;
@@ -61,7 +61,7 @@ ext::set < unsigned > BNDMOccurrences::query ( const indexes::stringology::BNDMM
 		currentBitmask.set ( );
 
 		while ( posInPattern > 0 && currentBitmask.any ( ) ) {
-			typename ext::map < SymbolType, std::bitset < BitmaskBitCount > >::const_iterator symbolVectorIter = pattern.getData ( ).find ( subject.getContent ( ).at ( posInSubject + posInPattern - 1 ) );
+			typename ext::map < SymbolType, ext::bitset < BitmaskBitCount > >::const_iterator symbolVectorIter = pattern.getData ( ).find ( subject.getContent ( ).at ( posInSubject + posInPattern - 1 ) );
 			if ( symbolVectorIter == pattern.getData ( ).end ( ) )
 				break;
 
diff --git a/alib2common/src/container/ObjectsBitset.h b/alib2common/src/container/ObjectsBitset.h
index f9c5a8d2b9..17da783f9a 100644
--- a/alib2common/src/container/ObjectsBitset.h
+++ b/alib2common/src/container/ObjectsBitset.h
@@ -34,19 +34,19 @@ public:
 	}
 
 	template < size_t N >
-	static std::bitset < N > parseRaw ( std::deque < sax::Token >::iterator & input );
+	static ext::bitset < N > parseRaw ( std::deque < sax::Token >::iterator & input );
 
 	template < size_t N >
-	static void compose ( std::deque < sax::Token > & out, const std::bitset < N > & input );
+	static void compose ( std::deque < sax::Token > & out, const ext::bitset < N > & input );
 };
 
 
 
 template < size_t N >
-std::bitset < N > ObjectsBitset::parseRaw ( std::deque < sax::Token >::iterator & input ) {
+ext::bitset < N > ObjectsBitset::parseRaw ( std::deque < sax::Token >::iterator & input ) {
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, ObjectsBitset::getXmlTagName() );
 
-	std::bitset < N > res;
+	ext::bitset < N > res;
 
 	for ( size_t i = 0; i < N; ++i )
 		res [ i ] = alib::xmlApi < bool >::parse ( input );
@@ -57,7 +57,7 @@ std::bitset < N > ObjectsBitset::parseRaw ( std::deque < sax::Token >::iterator
 }
 
 template < size_t N >
-void ObjectsBitset::compose ( std::deque < sax::Token > & out, const std::bitset < N > & container ) {
+void ObjectsBitset::compose ( std::deque < sax::Token > & out, const ext::bitset < N > & container ) {
 	out.emplace_back ( ObjectsBitset::getXmlTagName(), sax::Token::TokenType::START_ELEMENT );
 
 	for ( size_t i = 0; i < N; ++i )
@@ -71,30 +71,30 @@ void ObjectsBitset::compose ( std::deque < sax::Token > & out, const std::bitset
 namespace alib {
 
 template < size_t N >
-struct xmlApi < std::bitset < N > > {
-	static std::bitset < N > parse ( std::deque < sax::Token >::iterator & input );
+struct xmlApi < ext::bitset < N > > {
+	static ext::bitset < N > parse ( std::deque < sax::Token >::iterator & input );
 	static bool first ( const std::deque < sax::Token >::const_iterator & input );
 	static std::string xmlTagName ( );
-	static void compose ( std::deque < sax::Token > & output, const std::bitset < N > & data );
+	static void compose ( std::deque < sax::Token > & output, const ext::bitset < N > & data );
 };
 
 template < size_t N >
-std::bitset < N > xmlApi < std::bitset < N > >::parse ( std::deque < sax::Token >::iterator & input ) {
+ext::bitset < N > xmlApi < ext::bitset < N > >::parse ( std::deque < sax::Token >::iterator & input ) {
 	return container::ObjectsBitset::parseRaw < N > ( input );
 }
 
 template < size_t N >
-bool xmlApi < std::bitset < N > >::first ( const std::deque < sax::Token >::const_iterator & input ) {
+bool xmlApi < ext::bitset < N > >::first ( const std::deque < sax::Token >::const_iterator & input ) {
 	return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName() );
 }
 
 template < size_t N >
-std::string xmlApi < std::bitset < N > >::xmlTagName ( ) {
+std::string xmlApi < ext::bitset < N > >::xmlTagName ( ) {
 	return container::ObjectsBitset::getXmlTagName();
 }
 
 template < size_t N >
-void xmlApi < std::bitset < N > >::compose ( std::deque < sax::Token > & output, const std::bitset < N > & input ) {
+void xmlApi < ext::bitset < N > >::compose ( std::deque < sax::Token > & output, const ext::bitset < N > & input ) {
 	return container::ObjectsBitset::compose < N > ( output, input );
 }
 
diff --git a/alib2data/src/indexes/stringology/BNDMMatcher.h b/alib2data/src/indexes/stringology/BNDMMatcher.h
index 5893a803cb..7587cf2c47 100644
--- a/alib2data/src/indexes/stringology/BNDMMatcher.h
+++ b/alib2data/src/indexes/stringology/BNDMMatcher.h
@@ -45,7 +45,7 @@ class GeneralAlphabet;
 template < class SymbolType = DefaultSymbolType, size_t BitmaskBitCount = 64 >
 class BNDMMatcher final : public alib::ObjectBase, public alib::Components < BNDMMatcher < SymbolType >, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > {
 protected:
-	ext::map < SymbolType, std::bitset < BitmaskBitCount > > m_vectors;
+	ext::map < SymbolType, ext::bitset < BitmaskBitCount > > m_vectors;
 	ext::vector < SymbolType > m_string;
 
 public:
@@ -59,12 +59,12 @@ public:
 	 */
 	virtual ObjectBase * plunder ( ) &&;
 
-	explicit BNDMMatcher ( ext::set < SymbolType > alphabet, ext::map < SymbolType, std::bitset < BitmaskBitCount > > vectors, ext::vector < SymbolType > string );
+	explicit BNDMMatcher ( ext::set < SymbolType > alphabet, ext::map < SymbolType, ext::bitset < BitmaskBitCount > > vectors, ext::vector < SymbolType > string );
 
 	/**
 	 * @return Root node of the trie
 	 */
-	const ext::map < SymbolType, std::bitset < BitmaskBitCount > > & getData ( ) const;
+	const ext::map < SymbolType, ext::bitset < BitmaskBitCount > > & getData ( ) const;
 
 	const ext::vector < SymbolType > & getString ( ) const;
 
@@ -76,7 +76,7 @@ public:
 	 * Sets the bit vector for given symbol
 	 * @param tree root node to set
 	 */
-	void setBitVectorForSymbol ( SymbolType symbol, std::bitset < BitmaskBitCount > data );
+	void setBitVectorForSymbol ( SymbolType symbol, ext::bitset < BitmaskBitCount > data );
 
 	/**
 	 * Removes symbol from the alphabet of symbol available in the regular expression
@@ -123,8 +123,8 @@ public:
 
 		ext::set < DefaultSymbolType > alphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) );
 
-		ext::map < DefaultSymbolType, std::bitset < BitmaskBitCount > > vectors;
-		for ( std::pair < SymbolType, std::bitset < BitmaskBitCount > > && vector : ext::make_moveable_map ( m_vectors ) )
+		ext::map < DefaultSymbolType, ext::bitset < BitmaskBitCount > > vectors;
+		for ( std::pair < SymbolType, ext::bitset < BitmaskBitCount > > && vector : ext::make_moveable_map ( m_vectors ) )
 			vectors.insert ( std::make_pair ( alphabet::SymbolNormalize::normalizeSymbol ( std::move ( vector.first ) ), std::move ( vector.second ) ) );
 
 		ext::vector < DefaultSymbolType > string = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( m_string ) );
@@ -142,7 +142,7 @@ namespace indexes {
 namespace stringology {
 
 template < class SymbolType, size_t BitmaskBitCount >
-BNDMMatcher < SymbolType, BitmaskBitCount >::BNDMMatcher ( ext::set < SymbolType > alphabet, ext::map < SymbolType, std::bitset < BitmaskBitCount > > vectors, ext::vector < SymbolType > string ) : alib::Components < BNDMMatcher, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ), m_string ( std::move ( string ) ) {
+BNDMMatcher < SymbolType, BitmaskBitCount >::BNDMMatcher ( ext::set < SymbolType > alphabet, ext::map < SymbolType, ext::bitset < BitmaskBitCount > > vectors, ext::vector < SymbolType > string ) : alib::Components < BNDMMatcher, SymbolType, ext::tuple < GeneralAlphabet >, ext::tuple < > > ( ext::make_tuple ( std::move ( alphabet ) ), ext::tuple < > ( ) ), m_vectors ( std::move ( vectors ) ), m_string ( std::move ( string ) ) {
 }
 
 template < class SymbolType, size_t BitmaskBitCount >
@@ -156,7 +156,7 @@ alib::ObjectBase * BNDMMatcher < SymbolType, BitmaskBitCount >::plunder ( ) && {
 }
 
 template < class SymbolType, size_t BitmaskBitCount >
-const ext::map < SymbolType, std::bitset < BitmaskBitCount > > & BNDMMatcher < SymbolType, BitmaskBitCount >::getData ( ) const {
+const ext::map < SymbolType, ext::bitset < BitmaskBitCount > > & BNDMMatcher < SymbolType, BitmaskBitCount >::getData ( ) const {
 	return m_vectors;
 }
 
@@ -166,7 +166,7 @@ const ext::vector < SymbolType > & BNDMMatcher < SymbolType, BitmaskBitCount >::
 }
 
 template < class SymbolType, size_t BitmaskBitCount >
-void BNDMMatcher < SymbolType, BitmaskBitCount >::setBitVectorForSymbol ( SymbolType symbol, std::bitset < BitmaskBitCount > data ) {
+void BNDMMatcher < SymbolType, BitmaskBitCount >::setBitVectorForSymbol ( SymbolType symbol, ext::bitset < BitmaskBitCount > data ) {
 	this->m_vectors [ symbol ] = std::move ( data );
 }
 
@@ -196,7 +196,7 @@ template < class SymbolType, size_t BitmaskBitCount >
 BNDMMatcher < SymbolType, BitmaskBitCount > BNDMMatcher < SymbolType, BitmaskBitCount >::parse ( std::deque < sax::Token >::iterator & input ) {
 	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, BNDMMatcher::getXmlTagName() );
 	ext::set < SymbolType > alphabet = alib::xmlApi < ext::set < SymbolType > >::parse ( input );
-	ext::map < SymbolType, std::bitset < BitmaskBitCount > > data = alib::xmlApi < ext::map < SymbolType, std::bitset < BitmaskBitCount > > >::parse ( input );
+	ext::map < SymbolType, ext::bitset < BitmaskBitCount > > data = alib::xmlApi < ext::map < SymbolType, ext::bitset < BitmaskBitCount > > >::parse ( input );
 	ext::vector < SymbolType > string = alib::xmlApi < ext::vector < SymbolType > >::parse ( input );
 	BNDMMatcher < SymbolType, BitmaskBitCount > res ( std::move ( alphabet ), std::move ( data ), std::move ( string ) );
 
@@ -208,7 +208,7 @@ template < class SymbolType, size_t BitmaskBitCount >
 void BNDMMatcher < SymbolType, BitmaskBitCount >::compose ( std::deque < sax::Token > & out ) const {
 	out.emplace_back ( BNDMMatcher::getXmlTagName(), sax::Token::TokenType::START_ELEMENT );
 	alib::xmlApi < ext::set < SymbolType > >::compose ( out, getAlphabet ( ) );
-	alib::xmlApi < ext::map < SymbolType, std::bitset < BitmaskBitCount > > >::compose ( out, getData ( ) );
+	alib::xmlApi < ext::map < SymbolType, ext::bitset < BitmaskBitCount > > >::compose ( out, getData ( ) );
 	alib::xmlApi < ext::vector < SymbolType > >::compose ( out, getString ( ) );
 	out.emplace_back ( BNDMMatcher::getXmlTagName(), sax::Token::TokenType::END_ELEMENT );
 }
@@ -228,7 +228,7 @@ template < class SymbolType, size_t BitmaskBitCount >
 class ComponentConstraint < indexes::stringology::BNDMMatcher < SymbolType, BitmaskBitCount >, SymbolType, indexes::stringology::GeneralAlphabet > {
 public:
 	static bool used ( const indexes::stringology::BNDMMatcher < SymbolType, BitmaskBitCount > & index, const SymbolType & symbol ) {
-		const ext::map < SymbolType, std::bitset < BitmaskBitCount > > & content = index.getData ( );
+		const ext::map < SymbolType, ext::bitset < BitmaskBitCount > > & content = index.getData ( );
 		return content.find( symbol ) != content.end();
 	}
 
diff --git a/alib2std/src/extensions/bitset.hpp b/alib2std/src/extensions/bitset.hpp
index cb982c01ab..1462284153 100644
--- a/alib2std/src/extensions/bitset.hpp
+++ b/alib2std/src/extensions/bitset.hpp
@@ -15,10 +15,42 @@
 
 #include "compare.hpp"
 
-namespace std {
+namespace ext {
+
+template < std::size_t N >
+class bitset : public std::bitset < N > {
+public:
+#ifdef __clang__
+	using std::bitset < N >::bitset;
+	using std::bitset < N >::operator =;
+#else
+	bitset ( ) noexcept : std::bitset < N > ( ) {
+	}
+
+	bitset ( const bitset & other ) noexcept : std::bitset < N > ( other ) {
+	}
+
+	bitset ( bitset && other ) noexcept : std::bitset < N > ( std::move ( other ) ) {
+	}
+
+	using std::bitset < N >::bitset;
+
+	bitset & operator = ( bitset && other ) noexcept {
+		static_cast < std::bitset < N > & > ( * this ) = std::move ( other );
+		return * this;
+	}
+
+	bitset & operator = ( const bitset & other ) noexcept {
+		static_cast < std::bitset < N > & > ( * this ) = other;
+		return * this;
+	}
+
+	using std::bitset < N >::operator =;
+#endif
+};
 
 template < size_t N >
-std::ostream & operator << ( std::ostream & out, const std::bitset < N > & bitset ) {
+std::ostream & operator << ( std::ostream & out, const ext::bitset < N > & bitset ) {
 	out << "[";
 
 	for ( size_t i = 0; i < N; ++i ) {
@@ -30,13 +62,9 @@ std::ostream & operator << ( std::ostream & out, const std::bitset < N > & bitse
 	return out;
 }
 
-} /* namespace std */
-
-namespace ext {
-
 template < size_t N >
-struct compare < std::bitset < N > > {
-	int operator ( ) ( const std::bitset < N > & first, const std::bitset < N > & second ) const {
+struct compare < ext::bitset < N > > {
+	int operator ( ) ( const ext::bitset < N > & first, const ext::bitset < N > & second ) const {
 		for ( size_t i = 0; i < N; ++i ) {
 			int res = first [ i ] != second [ i ];
 			if ( res != 0 )
@@ -47,7 +75,7 @@ struct compare < std::bitset < N > > {
 };
 
 template < size_t N >
-std::string to_string ( const std::bitset < N > & value ) {
+std::string to_string ( const ext::bitset < N > & value ) {
 	std::stringstream ss;
 	ss << value;
 	return ss.str ( );
-- 
GitLab