SigUtil  0.95
Utility modules for modern C++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rest.hpp
Go to the documentation of this file.
1 /*
2 Copyright© 2014 Akihiro Nishimura
3 
4 This software is released under the MIT License.
5 http://opensource.org/licenses/mit-license.php
6 */
7 
8 #ifndef SIG_UTIL_REST_HPP
9 #define SIG_UTIL_REST_HPP
10 
11 #include "../helper/helper_modules.hpp"
12 #include "../helper/container_helper.hpp"
13 #include "../modify/sort.hpp"
14 
16 
17 namespace sig
18 {
20 
32 template <class T1, class T2,
33  class TC = typename std::common_type<T1, T2>::type,
34  class C = std::vector<TC>
35 >
36 C seqn(T1 st, T2 d, uint n)
37 {
38  C result = impl::container_traits<C>::make(n);
39 
40  for (uint i = 0; i<n; ++i) impl::container_traits<C>::add_element(result, static_cast<TC>(st) + i * static_cast<TC>(d));
41 
42  return result;
43 }
44 
45 #if SIG_GCC_GT4_8_0 || SIG_CLANG_GT_3_4 || !(SIG_MSVC_VER <= 120)
46 
48 
51 template <class F, class C,
52  typename std::enable_if<impl::container_traits<typename impl::remove_const_reference<C>::type>::exist>::type*& = enabler
53 >
54 auto sort(F&& binary_op, C&& data)
55 {
56  auto result = std::forward<C>(data);
57 
58  sort(result, std::forward<F>(binary_op));
59 
60  return result;
61 }
62 /*
63 template <class F, class C, typename std::enable_if<!impl::has_random_access_iter<C>::value, void>::type*& = enabler>
64 auto sort(F&& binary_op, C const& data
65 ){
66  C result = data;
67 
68  //result.sort(binary_op);
69 
70  return result;
71 }
72 */
73 #endif
74 
75 }
76 #endif
void * enabler
auto sort(C &container, F &&binary_op) -> decltype(impl::eval(std::forward< F >(binary_op), std::declval< T >(), std::declval< T >()), void())
標準ソート関数のラッパ
Definition: sort.hpp:46
Definition: array.hpp:15
C seqn(T1 st, T2 d, uint n)
等差数列
Definition: rest.hpp:36