Commit Graph

104 Commits

Author SHA1 Message Date
徐未来
b110613bee cxx 1.0.91升级至1.0.97
Signed-off-by: 徐未来 <xuweilai2@huawei.com>
2024-04-02 19:59:25 +08:00
openharmony_ci
96698d870d
回退 'Pull Request !11 : cxx1.0.91升级至1.0.97' 2024-04-02 03:30:32 +00:00
徐未来
e4f6feee96 1.0.91升级至1.0.97
Signed-off-by: 徐未来 <xuweilai2@huawei.com>
2024-03-08 16:36:47 +08:00
David Tolnay
1bda14d3dd
Add remark on build systems
Closes #1173.
2023-02-01 18:59:38 -08:00
kud1ing
9e7a622ca9
Example code for #[cxx::bridge]: struct MyType;=> type MyType; 2023-01-27 19:40:48 +01:00
David Tolnay
96606d570e
Fix missing <string> include in std::string example
The previous code works in _some_ STL implementations, namely if
_either_ of the following is true:

    1. At least one of the other four STL headers included by json.h
       transitively includes <string>, as opposed to just <stringfwd.h>; or

    2. The way std::variant is implemented does not require knowing the
       inner types' type traits when just naming the std::variant
       without yet instantiating any of its member function templates.

On other STL implementations in which neither of the above is true, this
example failed to build with an error such as:

    In file included from target/debug/build/example-d2d484e0c793273c/out/cxxbridge/sources/example/src/main.rs.cc:1:
    In file included from target/debug/build/example-d2d484e0c793273c/out/cxxbridge/crate/example/include/json.h:2:
    In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/map:60:
    In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_tree.h:63:
    In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algobase.h:64:
    In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:59:
    In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/move.h:57:
    /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/type_traits:1339:23: error: implicit instantiation of undefined template 'std::basic_string<char>'
                        __bool_constant<__has_trivial_destructor(_Tp)>>
                                        ^
    /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/type_traits:3214:5: note: in instantiation of template class 'std::is_trivially_destructible<std::basic_string<char>>' requested here
        is_trivially_destructible<_Tp>::value;
        ^
    /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/variant:299:5: note: in instantiation of variable template specialization 'std::is_trivially_destructible_v<std::basic_string<char>>' requested here
              (is_trivially_destructible_v<_Types> && ...);
               ^
    /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/variant:308:4: note: in instantiation of static data member 'std::__detail::__variant::_Traits<std::monostate, double, std::basic_string<char>, std::vector<json>, std::map<std::basic_string<char>, json>>::_S_trivial_dtor' requested here
              _S_trivial_dtor && _S_trivial_move_ctor
              ^
    /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/variant:689:45: note: in instantiation of static data member 'std::__detail::__variant::_Traits<std::monostate, double, std::basic_string<char>, std::vector<json>, std::map<std::basic_string<char>, json>>::_S_trivial_move_assign' requested here
          _Move_assign_base<_Traits<_Types...>::_S_trivial_move_assign, _Types...>;
                                                ^
    /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/variant:692:28: note: in instantiation of template type alias '_Move_assign_alias' requested here
        struct _Variant_base : _Move_assign_alias<_Types...>
                               ^
    /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/variant:1318:15: note: in instantiation of template class 'std::__detail::__variant::_Variant_base<std::monostate, double, std::basic_string<char>, std::vector<json>, std::map<std::basic_string<char>, json>>' requested here
        : private __detail::__variant::_Variant_base<_Types...>,
                  ^
    target/debug/build/example-d2d484e0c793273c/out/cxxbridge/crate/example/include/json.h:33:63: note: in instantiation of template class 'std::variant<std::monostate, double, std::basic_string<char>, std::vector<json>, std::map<std::basic_string<char>, json>>' requested here
      std::variant<std::monostate, number, string, array, object> value;
                                                                  ^
    /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stringfwd.h:74:11: note: template is declared here
        class basic_string;
              ^
2022-09-02 21:04:02 -07:00
Max Kalashnikoff
42da9b299d
Add geekbrother/cxx-corrosion-cmake repo to the CMake docs.
Update the CMake docs repositories list with the `geekbrother/cxx-corrosion-cmake` repository.
2022-09-01 17:39:26 +02:00
David Tolnay
bc6c82da7a
Touch up PR 1086 2022-08-29 13:47:31 -07:00
Preben Aandahl
546241a3b7 Added a CMake example application 2022-08-28 13:58:15 +02:00
David Tolnay
287ae044fe
Use upstreamed docs.rs icon in docs.rs badge 2022-06-11 10:17:10 -07:00
David Tolnay
a519f44e03
Reset white background on graphic 2022-04-10 17:55:54 -07:00
David Tolnay
bd252432f2
Convert overview diagram from svgbob to latex 2022-04-10 17:42:30 -07:00
David Tolnay
47465d2bf1
Touch up PR 984 2021-12-31 13:36:34 -08:00
David Tolnay
a4bc81f48a
Merge pull request #984 from benesch/lossy
Add String::lossy constructors to C++ API
2021-12-31 13:19:37 -08:00
Nikhil Benesch
3724105cea
Add String::lossy constructors to C++ API
This constructor maps to `String::from_utf8_lossy` or
`String::from_utf16_lossy`. It's useful in situations where producing a
slightly garbled string on invalid Unicode data is preferable to
crashing the process, e.g. when passing error messages from C++ to Rust.
2021-12-27 13:26:09 -05:00
Nikhil Benesch
e3918b5422
Add Vec<T>::truncate to C++ API
Based on the model of #951, which added `Vec<T>::clear`. The `truncate`
method is the more general form of clear.

(If we wanted to, we could delete the binding for `clear` and implement
`clear` as a call to `truncate(0)` on the C++ side, but seemed worth
leaving in in case the Rust `clear` implementation one day gets
smarter.)
2021-12-26 15:18:50 -05:00
David Tolnay
d662b6cbd4
Unhide "rust/cxx.h" at the time rust::Str is first used 2021-12-20 17:26:22 -08:00
David Tolnay
48f316d6ea
Merge pull request #886 from BKDaugherty/master
Add cxx include directive to blobstore header in middle example
2021-12-20 17:21:51 -08:00
David Tolnay
8bb18c37ff
Touch up PR 951 2021-12-08 17:13:41 -08:00
David Tolnay
aa3e828402
Merge pull request #951 from rookboom/vector_clear
Add Vec clear
2021-12-08 17:11:50 -08:00
David Tolnay
df31229dbf
Tweak head.hbs spacing to render neater with newest version of mdbook 2021-11-27 10:25:29 -08:00
David Tolnay
ede65e0ce2
Analytics compliant to GDPR without cookie consent 2021-11-01 17:14:10 -07:00
David Tolnay
fa350acb77
Set a google analytics 4 global site tag 2021-11-01 17:12:12 -07:00
Marcel Hlopko
0ad4fe5543 Migrate cxx for bazelbuild/rules_rust#591 2021-10-26 08:16:00 +02:00
Johan Verwey
54187c9e82
Added 'clear' method to rust::Vec 2021-10-20 08:10:32 -07:00
David Tolnay
8f56cbbace
Expose capacity and reserve on rust::String 2021-08-27 13:14:05 -07:00
David Tolnay
4309c43a5b
Remove rules that override rules_rust's default edition 2021-08-14 13:09:16 -07:00
David Tolnay
971082d9dc
Add rust::String utf-16 constructors to website 2021-08-03 10:50:22 -07:00
Brendon Daugherty
b4dde7e770 Add cxx include directive to blobstore header in the middle of the example 2021-06-14 23:39:01 -07:00
David Tolnay
251cf910eb
Merge pull request 882 from trondhe/master 2021-06-07 09:22:24 -07:00
Trond H Emaus
fb042fbd65 add additional cmake example 2021-06-07 15:47:19 +02:00
David Tolnay
060f1b4762
Document empty() member function in book 2021-04-28 00:32:11 -07:00
David Tolnay
cfdcede8f0
Rewrite raw ptr book page with example involving argc/argv 2021-03-22 19:29:12 -07:00
David Tolnay
bbb22b2b4e
Fix order of Rust version of T* vs const T* 2021-03-22 19:13:52 -07:00
David Tolnay
abe4ca47e3
Document restriction on passing raw ptr as argument 2021-03-22 19:13:52 -07:00
David Tolnay
420de87130
Register raw ptrs page in book table of contents
Otherwise the page does not even get rendered by mdbook.
2021-03-22 19:13:52 -07:00
David Tolnay
b47185f7e3
Order raw ptrs just above function ptrs in bindings list 2021-03-22 19:13:52 -07:00
David Tolnay
9fc8138823
Merge pull request #689 from adetaylor/pointers
Support raw pointers in cxx::bridge.
2021-03-22 19:04:37 -07:00
David Tolnay
de01edf706
Update C++ formatting to clang-format 11 2021-03-22 15:00:59 -07:00
Adrian Taylor
7d51573f82 Merge branch 'master' of github.com:dtolnay/cxx into pointers 2021-02-05 15:03:02 -08:00
Qinfan Wu
83d6366d65 Minor correction in the async example
The first argument of the closure is actually the context, not the
sender. Rename it to `context` to make it clearer. Was slightly confused
the first time I read it.
2021-01-31 12:57:33 -08:00
Adrian Taylor
75f417fff6 Documentation for raw pointers. 2021-01-24 08:57:45 -08:00
David Tolnay
a0b5fcb756
Update documentation to reflect opaque Rust types in slices and arrays 2021-01-04 12:18:24 -08:00
David Tolnay
fb5e1bad32
Add documentation about lifetimes to book 2021-01-03 20:05:43 -08:00
David Tolnay
0413ee2709
Restore swapping Str and Slice in member function form only 2021-01-02 13:57:48 -08:00
David Tolnay
815ca8cafc
Revert "Omit swap member functions from website"
This reverts commit d835ac6cad.
2021-01-02 13:57:30 -08:00
David Tolnay
2ae80499c1
Clean up trailing whitespaces 2021-01-02 12:28:02 -08:00
David Tolnay
d835ac6cad
Omit swap member functions from website
I feel it's sufficient that std::swap "does the right thing". These do
not need to be explicitly presented as part of the API.
2021-01-02 12:26:20 -08:00
David Tolnay
bc44ebf520
Touch up PR 642 2021-01-02 12:23:37 -08:00
David Tolnay
1ca730e0a1
Update Box website page to match header 2021-01-02 12:14:03 -08:00