Roger Leigh
2013-02-03 02:01:54 UTC
The attached patch introduces three macros:
AC_CXX_CONSTEXPR
AC_CXX_FINAL
AC_CXX_NULLPTR
which behave like AC_C_CONST et al but are for the new
C++11 constextr, final and nullptr keywords. I can add
additional macros for other keywords, but not all of them
have the possibility of falling back e.g. decltype, so I
have excluded these for now since I don't see these as
being useful additions.
I would also like to add checks for a number of types which
have implementations in the std:: (C++11) and std::tr1 (C++98TR1)
and boost:: (Boost) namespaces. Examples: regex, tuple, memory.
In many projects, I have logic in compatibility headers such as
follows. In brief, these include the std:: header (if present)
or else include the std::tr1 header (if present) or else include
the boost:: header (if present) or else fail. This permits once
to use the C++11 types with fallback to C++98TR1 or Boost being
completely transparent.
Would including macros such as AC_CXX_MEMORY, AC_CXX_TUPLE,
AC_CXX_REGEX etc. be acceptable? If so, is it acceptable to
include logic similar to the following in config.h or an
alternate header? Does autoconf allow the user to specify
which header will be used to e.g. redirect C++-specific
stuff to a specific header?
Regards,
Roger
# ifdef HAVE_MEMORY_SHARED_PTR
# include <memory>
# elif HAVE_TR1_MEMORY
# include <tr1/memory>
namespace std {
using std::tr1::shared_ptr;
using std::tr1::weak_ptr;
using std::tr1::static_pointer_cast;
using std::tr1::const_pointer_cast;
using std::tr1::dynamic_pointer_cast;
}
# elif HAVE_BOOST_SHARED_PTR_HPP
# include <boost/shared_ptr.hpp>
namespace std {
using boost::shared_ptr;
using boost::weak_ptr;
using boost::static_pointer_cast;
using boost::const_pointer_cast;
using boost::dynamic_pointer_cast;
}
# else
# error A shared_ptr implementation is not available
# endif
# ifdef HAVE_TUPLE
# include <tuple>
# elif HAVE_TR1_TUPLE
# include <tr1/tuple>
namespace std {
using tr1::tuple;
using tr1::get;
}
# elif HAVE_BOOST_TUPLE_TUPLE_HPP
# include <boost/tuple/tuple.hpp>
namespace std {
using boost::tuple;
using boost::get;
}
# else
# error A tuple implementation is not available
# endif
AC_CXX_CONSTEXPR
AC_CXX_FINAL
AC_CXX_NULLPTR
which behave like AC_C_CONST et al but are for the new
C++11 constextr, final and nullptr keywords. I can add
additional macros for other keywords, but not all of them
have the possibility of falling back e.g. decltype, so I
have excluded these for now since I don't see these as
being useful additions.
I would also like to add checks for a number of types which
have implementations in the std:: (C++11) and std::tr1 (C++98TR1)
and boost:: (Boost) namespaces. Examples: regex, tuple, memory.
In many projects, I have logic in compatibility headers such as
follows. In brief, these include the std:: header (if present)
or else include the std::tr1 header (if present) or else include
the boost:: header (if present) or else fail. This permits once
to use the C++11 types with fallback to C++98TR1 or Boost being
completely transparent.
Would including macros such as AC_CXX_MEMORY, AC_CXX_TUPLE,
AC_CXX_REGEX etc. be acceptable? If so, is it acceptable to
include logic similar to the following in config.h or an
alternate header? Does autoconf allow the user to specify
which header will be used to e.g. redirect C++-specific
stuff to a specific header?
Regards,
Roger
# ifdef HAVE_MEMORY_SHARED_PTR
# include <memory>
# elif HAVE_TR1_MEMORY
# include <tr1/memory>
namespace std {
using std::tr1::shared_ptr;
using std::tr1::weak_ptr;
using std::tr1::static_pointer_cast;
using std::tr1::const_pointer_cast;
using std::tr1::dynamic_pointer_cast;
}
# elif HAVE_BOOST_SHARED_PTR_HPP
# include <boost/shared_ptr.hpp>
namespace std {
using boost::shared_ptr;
using boost::weak_ptr;
using boost::static_pointer_cast;
using boost::const_pointer_cast;
using boost::dynamic_pointer_cast;
}
# else
# error A shared_ptr implementation is not available
# endif
# ifdef HAVE_TUPLE
# include <tuple>
# elif HAVE_TR1_TUPLE
# include <tr1/tuple>
namespace std {
using tr1::tuple;
using tr1::get;
}
# elif HAVE_BOOST_TUPLE_TUPLE_HPP
# include <boost/tuple/tuple.hpp>
namespace std {
using boost::tuple;
using boost::get;
}
# else
# error A tuple implementation is not available
# endif
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools
`- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools
`- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800