Skip to content

Commit

Permalink
refactor(IsSafePtr): comply with type_traits
Browse files Browse the repository at this point in the history
  • Loading branch information
e-kwsm committed Oct 15, 2023
1 parent ca32e0c commit f9d6732
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/bin/libint/iter.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ namespace libint2 {
typename SubIteratorBase<T,P>::cp_rettype
SubIteratorBase<T,P>::pelem() const
{
return PElemImpl<iter_type,detail::IsSafePtr<iref>::result>::pelem(elem());
return PElemImpl<iter_type,detail::IsSafePtr<iref>::value>::pelem(elem());
}

#if 0
Expand Down
24 changes: 6 additions & 18 deletions src/bin/libint/smart_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef _libint2_src_bin_libint_smartptr_h_
#define _libint2_src_bin_libint_smartptr_h_

#include <type_traits>
#include <libint2/config.h>

#if HAVE_SHARED_PTR_IN_BOOST
Expand Down Expand Up @@ -50,27 +51,14 @@
namespace libint2 {
namespace detail {
/** Can be used to determine whether a type is a SafePtr */
template <typename>
struct IsSafePtrHelper : std::false_type {};
template <typename T>
struct IsSafePtr {
enum { result = false };
};
struct IsSafePtrHelper<SafePtr<T>> : std::true_type {};

template <typename T>
struct IsSafePtr< SafePtr<T> > {
enum { result = true };
};
template <typename T>
struct IsSafePtr< const SafePtr<T> > {
enum { result = true };
};
template <typename T>
struct IsSafePtr< SafePtr<T>& > {
enum { result = true };
};
template <typename T>
struct IsSafePtr< const SafePtr<T>& > {
enum { result = true };
};
struct IsSafePtr : IsSafePtrHelper<typename std::remove_const<
typename std::remove_reference<T>::type>::type> {};
} // namespace detail
} // namespace libint2

Expand Down

0 comments on commit f9d6732

Please sign in to comment.