diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-25 20:32:06 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-25 20:32:06 +0300 |
commit | 0d49ea1fe08cf1eab41a00149393a291c65a59d7 (patch) | |
tree | 0391eb09309ca95282e200516937e64d89f3e1bb /odb-tests/common/view/olv/test7.hxx | |
parent | fc3fb39c90ab7fe5fccbe3f3bc0eb2645157bb96 (diff) |
Turn odb-tests repository into package for muti-package repositoryodb-tests
Diffstat (limited to 'odb-tests/common/view/olv/test7.hxx')
-rw-r--r-- | odb-tests/common/view/olv/test7.hxx | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/odb-tests/common/view/olv/test7.hxx b/odb-tests/common/view/olv/test7.hxx new file mode 100644 index 0000000..dbdc663 --- /dev/null +++ b/odb-tests/common/view/olv/test7.hxx @@ -0,0 +1,57 @@ +// file : common/view/olv/test7.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST7_HXX +#define TEST7_HXX + +#include <string> +#include <memory> // unique_ptr +#include <utility> // std::move + +#include <odb/core.hxx> + +// Test explicit conversion to smart pointer member. +// +#pragma db namespace table("t7_") pointer(*) session +namespace test7 +{ + using std::unique_ptr; + + #pragma db object + struct object1 + { + object1 (int n_ = 0): n (n_) {} + + #pragma db id auto + int id; + + int n; + }; + + #pragma db object + struct object2 + { + object2 () {} + object2 (const char* s_, object1* o1_): s (s_), o1 (o1_) {} + + #pragma db id auto + int id; + + std::string s; + object1* o1; // Shallow. + }; + + #pragma db view object(object1) object(object2) + struct view1 + { + // VC12 workaround (no default move constructor generation). + // + view1 () {} + view1 (view1&& x): o2 (std::move (x.o2)), o1 (std::move (x.o1)) {} + + unique_ptr<object2> o2; + unique_ptr<object1> o1; + }; +} + +#endif // TEST7_HXX |