Skip to content
Snippets Groups Projects
Commit feaf3833 authored by Timo Koch's avatar Timo Koch
Browse files

[std/typetraits] Deprecate Dune::Std::to_false/true_type. Use Dune::AlwaysFalse/True

parent f54750f5
No related branches found
No related tags found
2 merge requests!976Merge branch 'cleenup/deprecate-dune-disj-conj-neg-typetraits' into 'master',!971Deprecate Dune::Std::to_true_type and to_false_type
Pipeline #37730 passed with warnings
......@@ -11,6 +11,11 @@
- Deprecate fallback implementations `Dune::Std::apply`, `Dune::Std::bool_constant`, and
`Dune::Std::make_array` in favor of std c++ implementations.
- Deprecate type traits `Dune::Std::to_false_type`, `Dune::Std::to_true_type`.
`Dune::AlwaysFalse` and `Dune::AlwaysTrue` (from header `dune/common/typetraits.hh`)
now inherit from `std::true_type` and `std::false_type` and are therefore
exact replacements for these two type traits.
- Remove c++ feature tests in cmake for existing c++-17 standards. Add default
defines for `DUNE_HAVE_CXX_BOOL_CONSTANT`, `DUNE_HAVE_CXX_EXPERIMENTAL_BOOL_CONSTANT`,
`DUNE_HAVE_HEADER_EXPERIMENTAL_TYPE_TRAITS`, `DUNE_HAVE_CXX_APPLY`,
......
......@@ -19,7 +19,7 @@ namespace Dune {
* // Traits class that determines some property for some other type T
* template<class T>
* class SomeTraits {
* static_assert(Std::to_false_type<T>::value,
* static_assert(Dune::AlwaysFalse<T>::value,
* "Sorry, SomeTraits must be specialized for all types");
* public:
* // The type of some property of T
......
......@@ -1845,7 +1845,7 @@ namespace Dune {
*/
template<class V, class Rebinds,
template<class> class RebindPrune = IsLoop,
template<class> class RebindAccept = Std::to_true_type>
template<class> class RebindAccept = Dune::AlwaysTrue>
void check() {
// check whether the test for this type already started
if(seen_.emplace(typeid (V)).second == false)
......
......@@ -10,7 +10,7 @@
#include <dune/common/simd/loop.hh>
#include <dune/common/simd/test.hh>
#include <dune/common/simd/test/looptest.hh>
#include <dune/common/std/type_traits.hh>
#include <dune/common/typetraits.hh>
template<class> struct RebindAccept : std::false_type {};
#cmake @template@
......@@ -32,11 +32,11 @@ int main()
#cmake @template@
test.check<Dune::LoopSIMD<@SCALAR@, 5>,
Rebinds, Dune::Std::to_false_type, RebindAccept>();
Rebinds, Dune::AlwaysFalse, RebindAccept>();
test.check<Dune::LoopSIMD<@SCALAR@, 5, 64>,
Rebinds, Dune::Std::to_false_type, RebindAccept>();
Rebinds, Dune::AlwaysFalse, RebindAccept>();
test.check<Dune::LoopSIMD<Dune::LoopSIMD<@SCALAR@, 2>, 5>,
Rebinds, Dune::Std::to_false_type, RebindAccept>();
Rebinds, Dune::AlwaysFalse, RebindAccept>();
#cmake @endtemplate@
return test.good() ? EXIT_SUCCESS : EXIT_FAILURE;
......
......@@ -7,6 +7,7 @@
#include <cstdlib>
#include <type_traits>
#include <dune/common/typetraits.hh>
#include <dune/common/simd/test.hh>
#include <dune/common/simd/test/standardtest.hh>
......@@ -26,7 +27,7 @@ int main()
Dune::Simd::UnitTest test;
#cmake @template@
test.check<@SCALAR@, Rebinds, Dune::Std::to_false_type, RebindAccept>();
test.check<@SCALAR@, Rebinds, Dune::AlwaysFalse, RebindAccept>();
#cmake @endtemplate@
return test.good() ? EXIT_SUCCESS : EXIT_FAILURE;
......
......@@ -33,7 +33,7 @@ namespace Std
/** \class to_false_type
*
* \brief template mapping a type to <tt>std::false_type</tt>
*
* \deprecated Use Dune::AlwaysFalse (from dune/common/typetraits.hh) instead
* \tparam T Some type
*
* Suppose you have a template class. You want to document the required
......@@ -76,7 +76,7 @@ namespace Std
* \ingroup CxxUtilities
*/
template< typename T >
struct to_false_type : public std::false_type {};
struct [[deprecated("Will be removed after release 2.8. Use Dune::AlwaysFalse (from dune/common/typetraits.hh)")]] to_false_type : public std::false_type {};
......@@ -86,7 +86,7 @@ namespace Std
/** \class to_true_type
*
* \brief template mapping a type to <tt>std::true_type</tt>
*
* \deprecated Use Dune::AlwaysFalse (from dune/common/typetraits.hh) instead
* \tparam T Some type
*
* \note This class exists mostly for consistency with to_false_type.
......@@ -94,7 +94,7 @@ namespace Std
* \ingroup CxxUtilities
*/
template< typename T >
struct to_true_type : public std::true_type {};
struct [[deprecated("Will be removed after release 2.8. Use Dune::AlwaysTrue (from dune/common/typetraits.hh)")]] to_true_type : public std::true_type {};
/// A helper alias template std::bool_constant imported into the namespace Dune::Std
......
......@@ -5,6 +5,7 @@
#include <cstdlib>
#include <type_traits>
#include <dune/common/typetraits.hh>
#include <dune/common/debugalign.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/simd/test.hh>
......@@ -30,7 +31,7 @@ int main(int argc, char **argv)
#cmake @template@
test.check<Dune::AlignedNumber<@SCALAR@>,
Rebinds, Dune::Std::to_false_type, RebindAccept>();
Rebinds, Dune::AlwaysFalse, RebindAccept>();
#cmake @endtemplate@
return test.good() ? EXIT_SUCCESS : EXIT_FAILURE;
......
......@@ -10,7 +10,7 @@
#include <utility>
#include <dune/common/hybridutilities.hh>
#include <dune/common/std/type_traits.hh>
#include <dune/common/typetraits.hh>
namespace Dune {
......@@ -424,7 +424,7 @@ namespace Dune {
template<class Tuple, template<class> class Predicate, std::size_t size>
class FirstPredicateIndex<Tuple, Predicate, size, size>
{
static_assert(Std::to_false_type<Tuple>::value, "None of the std::tuple element "
static_assert(AlwaysFalse<Tuple>::value, "None of the std::tuple element "
"types matches the predicate!");
};
#endif // !DOXYGEN
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment