summaryrefslogtreecommitdiff
path: root/boost/bimap/tags/support
diff options
context:
space:
mode:
Diffstat (limited to 'boost/bimap/tags/support')
-rw-r--r--boost/bimap/tags/support/apply_to_value_type.hpp70
-rw-r--r--boost/bimap/tags/support/default_tagged.hpp73
-rw-r--r--boost/bimap/tags/support/is_tagged.hpp64
-rw-r--r--boost/bimap/tags/support/overwrite_tagged.hpp73
-rw-r--r--boost/bimap/tags/support/tag_of.hpp75
-rw-r--r--boost/bimap/tags/support/value_type_of.hpp74
6 files changed, 429 insertions, 0 deletions
diff --git a/boost/bimap/tags/support/apply_to_value_type.hpp b/boost/bimap/tags/support/apply_to_value_type.hpp
new file mode 100644
index 0000000..bb6aa60
--- /dev/null
+++ b/boost/bimap/tags/support/apply_to_value_type.hpp
@@ -0,0 +1,70 @@
+// Boost.Bimap
+//
+// Copyright (c) 2006-2007 Matias Capeletto
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \file tags/support/apply_to_value_type.hpp
+/// \brief Similar to mpl::apply but for tagged types.
+
+#ifndef BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP
+#define BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#include <boost/bimap/tags/tagged.hpp>
+#include <boost/mpl/apply.hpp>
+
+/** \struct boost::bimaps::tags::support::apply_to_value_type
+\brief Higger order metafunction similar to mpl::apply but for tagged types.
+
+\code
+template< class Metafunction, class TaggedType >
+struct apply_to_value_type
+{
+ typedef tagged
+ <
+ Metafuntion< value_type_of< TaggedType >::type >::type,
+ tag_of< TaggedType >::type
+
+ > type;
+};
+\endcode
+
+This higher order metafunctions is very useful, and it can be used with lambda
+expresions.
+
+See also tagged.
+ **/
+
+#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+namespace boost {
+namespace bimaps {
+namespace tags {
+namespace support {
+
+template < class F, class TaggedType >
+struct apply_to_value_type;
+
+template < class F, class ValueType, class Tag >
+struct apply_to_value_type<F, tagged<ValueType,Tag> >
+{
+ typedef BOOST_DEDUCED_TYPENAME mpl::apply< F, ValueType >::type new_value_type;
+ typedef tagged< new_value_type, Tag > type;
+};
+
+} // namespace support
+} // namespace tags
+} // namespace bimaps
+} // namespace boost
+
+#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+#endif // BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP
diff --git a/boost/bimap/tags/support/default_tagged.hpp b/boost/bimap/tags/support/default_tagged.hpp
new file mode 100644
index 0000000..4c02a65
--- /dev/null
+++ b/boost/bimap/tags/support/default_tagged.hpp
@@ -0,0 +1,73 @@
+// Boost.Bimap
+//
+// Copyright (c) 2006-2007 Matias Capeletto
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \file tags/support/default_tagged.hpp
+/// \brief Weak tagging
+
+#ifndef BOOST_BIMAP_TAGS_SUPPORT_DEFAULT_TAGGED_HPP
+#define BOOST_BIMAP_TAGS_SUPPORT_DEFAULT_TAGGED_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#include <boost/bimap/tags/tagged.hpp>
+
+/** \struct boost::bimaps::tags::support::default_tagged
+\brief Weak tagging metafunction
+
+\code
+template< class Type, class Tag >
+struct default_tagged
+{
+ typedef {TaggedType} type;
+};
+\endcode
+
+If the type is not tagged, this metafunction returns a tagged type with the
+default tag. If it is tagged, the returns the type unchanged.
+
+See also tagged, overwrite_tagged.
+ **/
+
+#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+namespace boost {
+namespace bimaps {
+namespace tags {
+namespace support {
+
+
+// Default Tagging
+// A metafunction that create a tagged type with a default tag value.
+
+template< class Type, class DefaultTag >
+struct default_tagged
+{
+ typedef tagged<Type,DefaultTag> type;
+};
+
+template< class Type, class OldTag, class NewTag >
+struct default_tagged< tagged< Type, OldTag >, NewTag >
+{
+ typedef tagged<Type,OldTag> type;
+};
+
+} // namespace support
+} // namespace tags
+} // namespace bimaps
+} // namespace boost
+
+#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+#endif // BOOST_BIMAP_TAGS_SUPPORT_DEFAULT_TAGGED_HPP
+
+
+
diff --git a/boost/bimap/tags/support/is_tagged.hpp b/boost/bimap/tags/support/is_tagged.hpp
new file mode 100644
index 0000000..892b3b1
--- /dev/null
+++ b/boost/bimap/tags/support/is_tagged.hpp
@@ -0,0 +1,64 @@
+// Boost.Bimap
+//
+// Copyright (c) 2006-2007 Matias Capeletto
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \file tags/support/is_tagged.hpp
+/// \brief type_traits extension
+
+#ifndef BOOST_BIMAP_TAGS_SUPPORT_IS_TAGGED_HPP
+#define BOOST_BIMAP_TAGS_SUPPORT_IS_TAGGED_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#include <boost/mpl/bool.hpp>
+#include <boost/bimap/tags/tagged.hpp>
+
+/** \struct boost::bimaps::tags::support::is_tagged
+\brief Type trait to check if a type is tagged.
+
+\code
+template< class Type >
+struct is_tagged
+{
+ typedef {mpl::true_/mpl::false_} type;
+};
+\endcode
+
+See also tagged.
+ **/
+
+#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+namespace boost {
+namespace bimaps {
+namespace tags {
+namespace support {
+
+
+// is_tagged metafunction
+
+template< class Type >
+struct is_tagged :
+ ::boost::mpl::false_ {};
+
+template< class Type, class Tag >
+struct is_tagged< tagged< Type, Tag > > :
+ ::boost::mpl::true_ {};
+
+} // namespace support
+} // namespace tags
+} // namespace bimaps
+} // namespace boost
+
+#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+#endif // BOOST_BIMAP_TAGS_SUPPORT_IS_TAGGED_HPP
+
diff --git a/boost/bimap/tags/support/overwrite_tagged.hpp b/boost/bimap/tags/support/overwrite_tagged.hpp
new file mode 100644
index 0000000..55cd0fc
--- /dev/null
+++ b/boost/bimap/tags/support/overwrite_tagged.hpp
@@ -0,0 +1,73 @@
+// Boost.Bimap
+//
+// Copyright (c) 2006-2007 Matias Capeletto
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \file tags/support/overwrite_tagged.hpp
+/// \brief Hard tagging
+
+#ifndef BOOST_BIMAP_TAGS_SUPPORT_OVERWRITE_TAGGED_HPP
+#define BOOST_BIMAP_TAGS_SUPPORT_OVERWRITE_TAGGED_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#include <boost/bimap/tags/tagged.hpp>
+
+/** \struct boost::bimaps::tags::support::overwrite_tagged
+\brief Hard tagging metafunction
+
+\code
+template< class Type, class Tag >
+struct overwrite_tagged
+{
+ typedef {TaggedType} type;
+};
+\endcode
+
+If the type is not tagged, this metafunction returns a tagged type with the
+passed tag. If it is tagged it returns a new tagged type with the tag replaced
+by the one passed as a parameter.
+
+See also tagged, default_tagged.
+ **/
+
+#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+namespace boost {
+namespace bimaps {
+namespace tags {
+namespace support {
+
+
+// Change the tag
+
+template< class Type, class NewTag >
+struct overwrite_tagged
+{
+ typedef tagged<Type,NewTag> type;
+};
+
+template< class Type, class OldTag, class NewTag >
+struct overwrite_tagged< tagged< Type, OldTag >, NewTag >
+{
+ typedef tagged<Type,NewTag> type;
+};
+
+
+} // namespace support
+} // namespace tags
+} // namespace bimaps
+} // namespace boost
+
+#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+#endif // BOOST_BIMAP_TAGS_SUPPORT_OVERWRITE_TAGGED_HPP
+
+
diff --git a/boost/bimap/tags/support/tag_of.hpp b/boost/bimap/tags/support/tag_of.hpp
new file mode 100644
index 0000000..413703b
--- /dev/null
+++ b/boost/bimap/tags/support/tag_of.hpp
@@ -0,0 +1,75 @@
+// Boost.Bimap
+//
+// Copyright (c) 2006-2007 Matias Capeletto
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \file tags/support/tag_of.hpp
+/// \brief Safe way to acces the tag of a type
+
+#ifndef BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP
+#define BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#include <boost/bimap/tags/tagged.hpp>
+#include <boost/bimap/detail/debug/static_error.hpp>
+
+/** \struct boost::bimaps::tags::support::tag_of
+\brief Metafunction to obtain the tag of a type.
+
+\code
+template< class TaggedType >
+struct tag_of
+{
+ typedef {Tag} type;
+};
+\endcode
+
+If the type is not tagged you will get a compile timer error with the following message:
+
+\verbatim
+USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, TaggedType
+\endverbatim
+
+See also tagged, value_type_of.
+ **/
+
+#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+namespace boost {
+namespace bimaps {
+namespace tags {
+namespace support {
+
+
+// tag_of metafunction
+
+template< class Type >
+struct tag_of
+{
+ BOOST_BIMAP_STATIC_ERROR( USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, (Type) );
+};
+
+template< class Type, class Tag >
+struct tag_of< tagged< Type, Tag > >
+{
+ typedef Tag type;
+};
+
+
+} // namespace support
+} // namespace tags
+} // namespace bimaps
+} // namespace boost
+
+#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+#endif // BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP
+
diff --git a/boost/bimap/tags/support/value_type_of.hpp b/boost/bimap/tags/support/value_type_of.hpp
new file mode 100644
index 0000000..a4ea828
--- /dev/null
+++ b/boost/bimap/tags/support/value_type_of.hpp
@@ -0,0 +1,74 @@
+// Boost.Bimap
+//
+// Copyright (c) 2006-2007 Matias Capeletto
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \file tags/support/value_type_of.hpp
+/// \brief Consistent way to access the value type of a tagged or untagged type.
+
+#ifndef BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP
+#define BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#include <boost/bimap/tags/tagged.hpp>
+
+/** \struct boost::bimaps::tags::support::value_type_of
+\brief Metafunction to work with tagged and untagged type uniformly
+
+\code
+template< class Type >
+struct value_type_of
+{
+ typedef {UntaggedType} type;
+};
+\endcode
+
+If the type is tagged this metafunction returns Type::value_type, and if it is not
+tagged it return the same type. This allows to work consistenly with tagged and
+untagged types.
+
+See also tagged, tag_of.
+ **/
+
+#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+
+namespace boost {
+namespace bimaps {
+namespace tags {
+namespace support {
+
+
+// value_type_of metafunction
+
+template< class Type >
+struct value_type_of
+{
+ typedef Type type;
+};
+
+template< class Type, class Tag >
+struct value_type_of< tagged< Type, Tag > >
+{
+ typedef Type type;
+};
+
+
+} // namespace support
+} // namespace tags
+} // namespace bimaps
+} // namespace boost
+
+#endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
+
+#endif // BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP
+
+