Skip to content

Commit f603205

Browse files
authored
Merge pull request #2496 from JohanMabille/adapt_doc
Fixed the documentation of adapt functions
2 parents 004370c + f1dc839 commit f603205

5 files changed

Lines changed: 149 additions & 39 deletions

File tree

docs/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PROJECT_NAME = "xtensor"
22
XML_OUTPUT = xml
3-
INPUT = missing_macro.hpp ../include
3+
INPUT = ../include
44
GENERATE_LATEX = NO
55
GENERATE_MAN = NO
66
GENERATE_RTF = NO

docs/source/api/xarray_adaptor.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Defined in ``xtensor/xarray.hpp``
1313
:project: xtensor
1414
:members:
1515

16-
adapt (xarray_adaptor)
17-
=======================
16+
adapt
17+
=====
1818

1919
Defined in ``xtensor/xadapt.hpp``
2020

@@ -36,8 +36,23 @@ Defined in ``xtensor/xadapt.hpp``
3636
.. doxygenfunction:: xt::adapt(T (&)[N], SC&&, SS&&)
3737
:project: xtensor
3838

39+
.. doxygenfunction:: xt::adapt(C&& pointer, const fixed_shape<X...>&);
40+
:project: xtensor
41+
42+
.. doxygenfunction:: xt::adapt(C&&, layout_type)
43+
:project: xtensor
44+
45+
.. doxygenfunction:: xt::adapt(P&&, typename A::size_type, O, layout_type, const A&)
46+
:project: xtensor
47+
3948
.. doxygenfunction:: xt::adapt_smart_ptr(P&&, const SC&, layout_type)
4049
:project: xtensor
4150

4251
.. doxygenfunction:: xt::adapt_smart_ptr(P&&, const SC&, D&&, layout_type)
4352
:project: xtensor
53+
54+
.. doxygenfunction:: xt::adapt_smart_ptr(P&&, const I (&)[N], layout_type)
55+
:project: xtensor
56+
57+
.. doxygenfunction:: xt::adapt_smart_ptr(P&&, const I (&)[N], D&&, layout_type)
58+
:project: xtensor

docs/source/api/xtensor_adaptor.rst

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,3 @@ Defined in ``xtensor/xtensor.hpp``
1313
:project: xtensor
1414
:members:
1515

16-
adapt (xtensor_adaptor)
17-
========================
18-
19-
Defined in ``xtensor/xadapt.hpp``
20-
21-
.. doxygenfunction:: xt::adapt(C&&, layout_type)
22-
:project: xtensor
23-
24-
.. doxygenfunction:: xt::adapt(C&&, const SC&, layout_type)
25-
:project: xtensor
26-
27-
.. doxygenfunction:: xt::adapt(C&&, SC&&, SS&&)
28-
:project: xtensor
29-
30-
.. doxygenfunction:: xt::adapt(P&&, typename A::size_type, O, layout_type, const A&)
31-
:project: xtensor
32-
33-
.. doxygenfunction:: xt::adapt(P&&, typename A::size_type, O, const SC&, layout_type, const A&)
34-
:project: xtensor
35-
36-
.. doxygenfunction:: xt::adapt(P&&, typename A::size_type, O, SC&&, SS&&, const A&)
37-
:project: xtensor
38-
39-
.. doxygenfunction:: xt::adapt(T (&)[N], const SC&, layout_type)
40-
:project: xtensor
41-
42-
.. doxygenfunction:: xt::adapt(T (&)[N], SC&&, SS&&)
43-
:project: xtensor
44-
45-
.. doxygenfunction:: xt::adapt_smart_ptr(P&&, const I (&)[N], layout_type)
46-
:project: xtensor
47-
48-
.. doxygenfunction:: xt::adapt_smart_ptr(P&&, const I (&)[N], D&&, layout_type)
49-
:project: xtensor

include/xtensor/xadapt.hpp

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ namespace xt
5757
using not_a_layout = xtl::negation<std::is_same<layout_type,T>>;
5858
}
5959

60+
#ifndef IN_DOXYGEN
61+
6062
/**************************
6163
* xarray_adaptor builder *
6264
**************************/
@@ -202,7 +204,7 @@ namespace xt
202204
/***************************
203205
* xtensor_adaptor builder *
204206
***************************/
205-
207+
206208
/**
207209
* Constructs a 1-D xtensor_adaptor of the given stl-like container,
208210
* with the specified layout_type.
@@ -403,6 +405,132 @@ namespace xt
403405
return adapt(std::forward<C>(ptr), xtl::forward_sequence<shape_type, decltype(shape)>(shape));
404406
}
405407

408+
#else // IN_DOXYGEN
409+
410+
/**
411+
* Constructs:
412+
* - an xarray_adaptor if SC is not an array type
413+
* - an xtensor_adaptor if SC is an array type
414+
*
415+
* from the given stl-like container or pointer, with the specified shape and layout.
416+
* If the adaptor is built from a pointer, it does not take its ownership.
417+
* @param container the container or pointer to adapt
418+
* @param shape the shape of the adaptor
419+
* @param l the layout_type of the adaptor
420+
*/
421+
template <layout_type L = XTENSOR_DEFAULT_LAYOUT, class C, class SC>
422+
inline auto adapt(C&& container, const SC& shape, layout_type l = L);
423+
424+
/**
425+
* Constructs:
426+
* - an xarray_adaptor if SC is not an array type
427+
* - an xtensor_adaptor if SC is an array type
428+
*
429+
* from the given stl-like container with the specified shape and strides.
430+
* @param container the container to adapt
431+
* @param shape the shape of the adaptor
432+
* @param strides the strides of the adaptor
433+
*/
434+
template <class C, class SC, class SS>
435+
inline auto adapt(C&& container, SC&& shape, SS&& strides);
436+
437+
/**
438+
* Constructs:
439+
* - an xarray_adaptor if SC is not an array type
440+
* - an xtensor_adaptor if SC is an array type
441+
*
442+
* of the given dynamically allocated C array, with the specified shape and layout.
443+
* @param pointer the pointer to the beginning of the dynamic array
444+
* @param size the size of the dynamic array
445+
* @param ownership indicates whether the adaptor takes ownership of the array.
446+
* Possible values are ``no_ownership()`` or ``acquire_ownership()``
447+
* @param shape the shape of the adaptor
448+
* @param l the layout_type of the adaptor
449+
* @param alloc the allocator used for allocating / deallocating the dynamic array
450+
*/
451+
template <layout_type L = XTENSOR_DEFAULT_LAYOUT, class P, class O, class SC, class A = detail::default_allocator_for_ptr_t<P>>
452+
inline auto
453+
adapt(P&& pointer, typename A::size_type size, O ownership, const SC& shape, layout_type l = L, const A& alloc = A());
454+
455+
/**
456+
* Constructs:
457+
* - an xarray_adaptor if SC is not an array type
458+
* - an xtensor_adaptor if SC is an array type
459+
*
460+
* of the given dynamically allocated C array, with the specified shape and strides.
461+
* @param pointer the pointer to the beginning of the dynamic array
462+
* @param size the size of the dynamic array
463+
* @param ownership indicates whether the adaptor takes ownership of the array.
464+
* Possible values are ``no_ownership()`` or ``acquire_ownership()``
465+
* @param shape the shape of the adaptor
466+
* @param strides the strides of the adaptor
467+
* @param alloc the allocator used for allocating / deallocating the dynamic array
468+
*/
469+
template <class P, class O, class SC, class SS, class A = detail::default_allocator_for_ptr_t<P>>
470+
inline auto
471+
adapt(P&& pointer, typename A::size_type size, O ownership, SC&& shape, SS&& strides, const A& alloc = A());
472+
473+
/**
474+
* Contructs:
475+
* - an xarray_adaptor if SC is not an array type
476+
* - an xtensor_adaptor if SC is an array type
477+
*
478+
* of the given C array allocated on the stack, with the specified shape and layout.
479+
* @param c_array the C array allocated on the stack
480+
* @param shape the shape of the adaptor
481+
* @param l the layout_type of the adaptor
482+
*/
483+
template <layout_type L = XTENSOR_DEFAULT_LAYOUT, class T, std::size_t N, class SC>
484+
inline auto adapt(T (&c_array)[N], const SC& shape, layout_type l = L);
485+
486+
/**
487+
* Contructs:
488+
* - an xarray_adaptor if SC is not an array type
489+
* - an xtensor_adaptor if SC is an array type
490+
*
491+
* of the given C array allocated on the stack, with the
492+
* specified shape and strides.
493+
* @param c_array the C array allocated on the stack
494+
* @param shape the shape of the adaptor
495+
* @param strides the strides of the adaptor
496+
*/
497+
template <class T, std::size_t N, class SC, class SS>
498+
inline auto adapt(T (&c_array)[N], SC&& shape, SS&& strides);
499+
500+
/**
501+
* Constructs an non-owning xtensor_fixed_adaptor from a pointer with the
502+
* specified shape and layout.
503+
* @param pointer the pointer to adapt
504+
* @param shape the shape of the xtensor_fixed_adaptor
505+
*/
506+
template <layout_type L = XTENSOR_DEFAULT_LAYOUT, class C, std::size_t... X>
507+
inline auto adapt(C&& pointer, const fixed_shape<X...>& /*shape*/);
508+
509+
/**
510+
* Constructs a 1-D xtensor_adaptor of the given stl-like container,
511+
* with the specified layout_type.
512+
* @param container the container to adapt
513+
* @param l the layout_type of the xtensor_adaptor
514+
*/
515+
template <layout_type L = XTENSOR_DEFAULT_LAYOUT, class C>
516+
inline xtensor_adaptor<C, 1, L> adapt(C&& container, layout_type l = L);
517+
518+
/**
519+
* Constructs a 1-D xtensor_adaptor of the given dynamically allocated C array,
520+
* with the specified layout.
521+
* @param pointer the pointer to the beginning of the dynamic array
522+
* @param size the size of the dynamic array
523+
* @param ownership indicates whether the adaptor takes ownership of the array.
524+
* Possible values are ``no_ownership()`` or ``acquire_ownership()``
525+
* @param l the layout_type of the xtensor_adaptor
526+
* @param alloc the allocator used for allocating / deallocating the dynamic array
527+
*/
528+
template <layout_type L = XTENSOR_DEFAULT_LAYOUT, class P, class O, class A = detail::default_allocator_for_ptr_t<P>>
529+
inline xtensor_adaptor<xbuffer_adaptor<xtl::closure_type_t<P>, O, A>, 1, L>
530+
adapt(P&& pointer, typename A::size_type size, O ownership, layout_type l = L, const A& alloc = A());
531+
532+
#endif // IN_DOXYGEN
533+
406534
/*****************************
407535
* smart_ptr adapter builder *
408536
*****************************/

include/xtensor/xeval.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace xt
4747
{
4848
return std::forward<T>(t);
4949
}
50+
/// @endcond
5051

5152
namespace detail
5253
{
@@ -144,7 +145,6 @@ namespace xt
144145
return e;
145146
}
146147

147-
/// @cond DOXYGEN_INCLUDE_SFINAE
148148
template <layout_type L = layout_type::any, class E>
149149
inline auto as_strided(E&& e)
150150
-> std::enable_if_t<(!(has_data_interface<std::decay_t<E>>::value
@@ -154,6 +154,7 @@ namespace xt
154154
{
155155
return e;
156156
}
157+
/// @endcond
157158
}
158159

159160
#endif

0 commit comments

Comments
 (0)