Hello everyone.
I am trying to run AMPL C++ API with C++20, but I am having some problems with this. Inside my AMPL folder /opt/ampl/amplapi/examples/cpp, I type:
g++ -std=c++11 -Wall -o firstexample firstexample.cc -I…/…/include -L…/…/lib -lampl
As suggested here https://groups.google.com/g/ampl/c/QAPhvArF7Bs/m/4NnDJs13BAAJ. Which works just fine, but if I try to do the same by using c++20
g++ -std=c++20 -Wall -o firstexample firstexample.cc -I…/…/include -L…/…/lib -lampl
I get the following messages:
In file included from …/…/include/ampl/amplexception.h:8,
from …/…/include/ampl/ep/errorinfo_ep.h:6,
from …/…/include/ampl/variant.h:7,
from …/…/include/ampl/ep/arg.h:4,
from …/…/include/ampl/dataframe.h:4,
from …/…/include/ampl/ampl.h:4,
from firstexample.cc:3:
…/…/include/ampl/format.h: In instantiation of ‘void fmt::internal::MemoryBuffer<T, SIZE, Allocator>::grow(std::size_t) [with T = wchar_t; long unsigned int SIZE = 500; Allocator = std::allocator<wchar_t>; std::size_t = long unsigned int]’:
…/…/include/ampl/format.h:799:6: required from here
…/…/include/ampl/format.h:802:30: error: no matching function for call to ‘fmt::internal::MemoryBuffer<wchar_t, 500, std::allocator<wchar_t> >::allocate(std::size_t&, std::nullptr_t)’
802 | T new_ptr = this->allocate(new_capacity, FMT_NULL);
__| ~^~~____
In file included from /usr/include/c++/11/string:41,
from /usr/include/c++/11/bits/locale_classes.h:40,
from /usr/include/c++/11/bits/ios_base.h:41,
from /usr/include/c++/11/ios:42,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from firstexample.cc:1:
/usr/include/c++/11/bits/allocator.h:179:7: note: candidate: ‘constexpr _Tp std::allocator< >::allocate(std::size_t) [with _Tp = wchar_t; std::size_t = long unsigned int]’
179 | allocate(size_t __n)
__*| ^
__/usr/include/c++/11/bits/allocator.h:179:7: note: candidate expects 1 argument, 2 provided*__
In file included from …/…/include/ampl/amplexception.h:8,
from …/…/include/ampl/ep/errorinfo_ep.h:6,
from …/…/include/ampl/variant.h:7,
from …/…/include/ampl/ep/arg.h:4,
from …/…/include/ampl/dataframe.h:4,
from …/…/include/ampl/ampl.h:4,
from firstexample.cc:3:
…/…/include/ampl/format.h: In instantiation of ‘void fmt::internal::MemoryBuffer<T, SIZE, Allocator>::grow(std::size_t) [with T = char; long unsigned int SIZE = 500; Allocator = std::allocator; std::size_t = long unsigned int]’:
…/…/include/ampl/format.h:799:6: required from here
…/…/include/ampl/format.h:802:30: error: no matching function for call to ‘fmt::internal::MemoryBuffer<char, 500, std::allocator >::allocate(std::size_t&, std::nullptr_t)’
802 | T new_ptr = this->allocate(new_capacity, FMT_NULL);
__| ^~____
In file included from /usr/include/c++/11/string:41,
from /usr/include/c++/11/bits/locale_classes.h:40,
from /usr/include/c++/11/bits/ios_base.h:41,
from /usr/include/c++/11/ios:42,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from firstexample.cc:1:
/usr/include/c++/11/bits/allocator.h:179:7: note: candidate: ‘constexpr _Tp std::allocator< >::allocate(std::size_t) [with _Tp = char; std::size_t = long unsigned int]’
179 | allocate(size_t __n)
__*| ^
__/usr/include/c++/11/bits/allocator.h:179:7: note: candidate expects 1 argument, 2 provided*__
I would like to know if someone ever tried using the AMPL C++ API with C++20.
Thanks and best regards.