It seems that there are a few problems with the current code:
The code needs #include <iterator> to compile properly.
ccapi::Session lacks a move constructor.
ccapi::Session lacks a move-assignment operator
I am using g++
# g++ --version
g++ (GCC) 13.1.1 20230511 (Red Hat 13.1.1-2)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
An example program which shows missing #include <iterator> and missing move constructor:
#include <ccapi_cpp/ccapi_session.h>
int main (void)
{
ccapi::Session session {};
ccapi::Session session2 {std::move (session)};
return 0;
}
Trying to compile it gives:
# g++ -std=c++20 ./session.cpp
In file included from /usr/local/include/ccapi_cpp/ccapi_logger.h:76,
from /usr/local/include/ccapi_cpp/ccapi_event.h:5,
from /usr/local/include/ccapi_cpp/ccapi_session.h:241,
from ./session.cpp:1:
/usr/local/include/ccapi_cpp/ccapi_util_private.h: In static member function ‘static std::string ccapi::UtilString::join(const std::vector<std::__cxx11::basic_string<char> >&, const std::string&)’:
/usr/local/include/ccapi_cpp/ccapi_util_private.h:174:60: error: ‘ostream_iterator’ is not a member of ‘std’
174 | std::copy(strings.begin(), strings.end() - 1, std::ostream_iterator<std::string>(joined, delimiter.c_str()));
| ^~~~~~~~~~~~~~~~
/usr/local/include/ccapi_cpp/ccapi_util_private.h:30:1: note: ‘std::ostream_iterator’ is defined in header ‘<iterator>’; did you forget to ‘#include <iterator>’?
29 | #include "openssl/evp.h"
+++ |+#include <iterator>
30 | namespace ccapi {
/usr/local/include/ccapi_cpp/ccapi_util_private.h:174:88: error: expected primary-expression before ‘>’ token
174 | std::copy(strings.begin(), strings.end() - 1, std::ostream_iterator<std::string>(joined, delimiter.c_str()));
| ^
./session.cpp: In function ‘int main()’:
./session.cpp:6:53: error: use of deleted function ‘ccapi::Session::Session(const ccapi::Session&)’
6 | ccapi::Session session2 {std::move (session)};
| ^
/usr/local/include/ccapi_cpp/ccapi_session.h:259:3: note: declared here
259 | Session(const Session&) = delete;
| ^~~~~~~
An example program which shows missing #include <iterator> and missing move-assignment operator:
#include <ccapi_cpp/ccapi_session.h>
int main (void)
{
ccapi::Session session {};
ccapi::Session session2 {};
session2 = std::move (session);
return 0;
}
Trying to compile it gives:
# g++ -std=c++20 ./session.cpp
In file included from /usr/local/include/ccapi_cpp/ccapi_logger.h:76,
from /usr/local/include/ccapi_cpp/ccapi_event.h:5,
from /usr/local/include/ccapi_cpp/ccapi_session.h:241,
from ./session.cpp:1:
/usr/local/include/ccapi_cpp/ccapi_util_private.h: In static member function ‘static std::string ccapi::UtilString::join(const std::vector<std::__cxx11::basic_string<char> >&, const std::string&)’:
/usr/local/include/ccapi_cpp/ccapi_util_private.h:174:60: error: ‘ostream_iterator’ is not a member of ‘std’
174 | std::copy(strings.begin(), strings.end() - 1, std::ostream_iterator<std::string>(joined, delimiter.c_str()));
| ^~~~~~~~~~~~~~~~
/usr/local/include/ccapi_cpp/ccapi_util_private.h:30:1: note: ‘std::ostream_iterator’ is defined in header ‘<iterator>’; did you forget to ‘#include <iterator>’?
29 | #include "openssl/evp.h"
+++ |+#include <iterator>
30 | namespace ccapi {
/usr/local/include/ccapi_cpp/ccapi_util_private.h:174:88: error: expected primary-expression before ‘>’ token
174 | std::copy(strings.begin(), strings.end() - 1, std::ostream_iterator<std::string>(joined, delimiter.c_str()));
| ^
./session.cpp: In function ‘int main()’:
./session.cpp:7:38: error: use of deleted function ‘ccapi::Session& ccapi::Session::operator=(const ccapi::Session&)’
7 | session2 = std::move (session);
| ^
/usr/local/include/ccapi_cpp/ccapi_session.h:260:12: note: declared here
260 | Session& operator=(const Session&) = delete;
| ^~~~~~~~
It seems that there are a few problems with the current code:
#include <iterator>
to compile properly.I am using g++
An example program which shows missing
#include <iterator>
and missing move constructor:Trying to compile it gives:
An example program which shows missing
#include <iterator>
and missing move-assignment operator:Trying to compile it gives: