Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add is_bool #190

Open
gpeterhoff opened this issue Feb 4, 2024 · 3 comments
Open

add is_bool #190

gpeterhoff opened this issue Feb 4, 2024 · 3 comments

Comments

@gpeterhoff
Copy link

is_bool.hpp

//	Distributed under the Boost Software License Version 1.0 https://www.boost.org/LICENSE_1_0.txt
//	Copyright Gero Peterhoff

#ifndef BOOST_TYPE_TRAITS_IS_BOOL_HPP
#define BOOST_TYPE_TRAITS_IS_BOOL_HPP

#include <boost/type_traits/remove_cvref.hpp>
#include <boost/type_traits/is_same.hpp>



namespace boost
{
template <typename Type> struct is_bool : public integral_constant
<
	bool,
	is_same<typename remove_cvref<Type>::type, bool>::value
>	{};



#if !defined(BOOST_NO_CXX17_INLINE_VARIABLES)
template <typename Type> inline constexpr bool is_bool_v = is_bool<Type>::value;
#endif
}	//	boost

#endif	//	BOOST_TYPE_TRAITS_IS_BOOL_HPP
@gpeterhoff gpeterhoff changed the title add is_bool.bpp add is_bool Feb 4, 2024
@jzmaddock
Copy link
Collaborator

Clearly we can add this, but in the many years of type_traits existence, no one has ever asked for it, looks a bit too trivial to me.

@gpeterhoff
Copy link
Author

It is therefore high time to make this available.
I don't even want to know how many people have already programmed around it ...

@pdimov
Copy link
Member

pdimov commented Feb 5, 2024

The only use I can give for this (somewhat trivial) trait is that in Endian, a lot of the functions take "an integral type that is not bool".

It only saves one remove_cv in comparison to is_same<T, bool>, but so does is_void.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants