1//----------------------------------------------------------------------------
2/// @file traits.hpp
3/// @brief this file contains the metaprogramming classes compare_iter and
4/// enable_if_not_integral
5/// @author Copyright(c) 2016 Francisco Jose Tapia (fjtapia@gmail.com )\n
6/// Distributed under the Boost Software License, Version 1.0.\n
7/// ( See accompanying file LICENSE_1_0.txt or copy at
8/// http://www.boost.org/LICENSE_1_0.txt )
9/// @version 0.1
10///
11//-----------------------------------------------------------------------------
12#ifndef __BOOST_SORT_COMMON_UTIL_TRAITS_HPP
13#define __BOOST_SORT_COMMON_UTIL_TRAITS_HPP
14
15#include <ciso646>
16#include <functional>
17#include <iterator>
18#include <type_traits>
19
20namespace boost
21{
22namespace sort
23{
24namespace common
25{
26namespace util
27{
28//----------------------------------------------------------------------------
29// USING SENTENCES
30//----------------------------------------------------------------------------
31using std::iterator_traits;
32
33//
34//---------------------------------------------------------------------------
35/// @class value_iter
36/// @brief From the iterator, obtain the type pointed by it
37/// @remarks The main utility of this, is simplify the default template
38/// parameter of comparison
39//---------------------------------------------------------------------------
40template<class iter_t>
41using value_iter = typename iterator_traits< iter_t >::value_type;
42//
43//---------------------------------------------------------------------------
44/// @class compare_iter
45/// @brief From the iterator, received as template parameter, obtain the type
46/// of the object pointed by the iterator, and with this define the
47/// std::less with this type obtained
48/// @remarks The main utility of this, is simplify the default template
49/// parameter of comparison
50//---------------------------------------------------------------------------
51template<class iter_t>
52using compare_iter = std::less< value_iter< iter_t > >;
53
54//
55//---------------------------------------------------------------------------
56/// @class enable_if_not_integral
57/// @brief This is a SFINAE class for to detect if the third parameter in the
58/// invocation of the parallel sorting algorithms is an integer
59/// representing the number of threads to use or is a comparison object
60/// @remarks
61//---------------------------------------------------------------------------
62template<class T>
63using enable_if_not_integral =
64 typename std::enable_if< !std::is_integral< T >::value >::type;
65//
66//---------------------------------------------------------------------------
67/// @class enable_if_integral
68/// @brief This is a SFINAE class for to detect if the third parameter in the
69/// invocation of the parallel sorting algorithms is an integer
70/// representing the number of threads to use or is a comparison object
71/// @remarks
72//---------------------------------------------------------------------------
73template<class T>
74using enable_if_integral =
75 typename std::enable_if< std::is_integral< T >::value >::type;
76
77//
78//---------------------------------------------------------------------------
79/// @class enable_if_string
80/// @brief This is a SFINAE class for to detect if the parameter is a
81/// std::string for to apply specialized parameters in the invocation
82/// of the block_indirect_sort algorithm
83/// @remarks
84//---------------------------------------------------------------------------
85template<class T>
86using enable_if_string =
87 typename std::enable_if< std::is_same< T, std::string >::value >::type;
88
89//
90//---------------------------------------------------------------------------
91/// @class enable_if_not_string
92/// @brief This is a SFINAE class for to detect if the parameter is a
93/// std::string for to apply specialized parameters in the invocation
94/// of the block_indirect_sort algorithm
95/// @remarks
96//---------------------------------------------------------------------------
97template<class T>
98using enable_if_not_string =
99 typename std::enable_if<! std::is_same< T, std::string >::value >::type;
100
101//
102//---------------------------------------------------------------------------
103/// @class constructor
104/// @brief create a functor with the constructor of a class for to be invoked
105/// from a bind or a lambda
106/// @remarks
107//---------------------------------------------------------------------------
108template<class T>
109struct constructor
110{
111 template<class ... Args>
112 void operator()(Args && ... args)
113 {
114 T(std::forward<Args> (args) ...);
115 }
116};
117//
118//****************************************************************************
119};// End namespace util
120};// End namespace common
121};// End namespace sort
122};// End namespace boost
123//****************************************************************************
124#endif
125

source code of boost/libs/sort/include/boost/sort/common/util/traits.hpp