Gcc Error Forming Pointer To Reference Type
here for a quick overview of the site Help
Std Vector Of References
Center Detailed answers to any questions you might have std::reference_wrapper Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Why do I get an error in “forming reference to reference type” map? up vote 11 down vote favorite 4 What is the alternative if I need to use a reference, and the data I am passing I cannot change the type of, hence I cannot really store a pointer to it? Code: #include
c++ vector If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 3 of 3 Thread: c++ vector Tweet Thread Tools Show Printable Version Email this Page… http://stackoverflow.com/questions/1155142/why-do-i-get-an-error-in-forming-reference-to-reference-type-map Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 01-08-2007,11:36 PM #1 spx2 View Profile View Forum Posts sadgasdgaswq Join Date Mar 2005 Location asdhsadgas Posts 197 c++ vector why can't i use vector < int& > ? in bruce eckel vol I thinking in C++ there's an http://forums.justlinux.com/showthread.php?148044-c-vector excercice about this,and it asks if its possible to create a structure as above. now my question is why can't one create such a structure ? my gut feeling is because the references in the vector would have to be initialized , but i'm not sure. anyway i get allot of errors on my compiler can someone please explain this ? thank you i'm stupid Reply With Quote 01-08-2007,11:52 PM #2 spx2 View Profile View Forum Posts sadgasdgaswq Join Date Mar 2005 Location asdhsadgas Posts 197 for the following source Code: #include #include //#include //#include //#include //#include //#include #include //#include using namespace std; class jadsafa{}; int main(){ vector g; vector has; return 0; } i get this Code: C:\WINDOWS\system32\cmd.exe /c g++ vectortst.cpp c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ext/new_allo cator.h: In instantiation of `__gnu_cxx::new_allocator': c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/allocat or.h:81: instantiated from `std::allocator' c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_vec tor.h:79: instantiated from `std::_Vector_base >::_Vector_impl' c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_vec tor.h:110: instantiated from `std::_Vector_base >' c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/st
account creation filtered due to spam. Bug29515 - error: forming reference to reference https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29515 type X. Summary: error: forming reference to reference type X. Status: RESOLVED DUPLICATE of bug 7412 Alias: None Product: gcc Classification: Unclassified Component: libstdc++ (show other http://ideone.com/cbAeN7 bugs) Version: 4.1.2 Importance: P3 normal Target Milestone: --- Assignee: Not yet assigned to anyone URL: Keywords: rejects-valid Depends on: Blocks: Reported: 2006-10-19 11:53 UTC by gcc error Pawel Sikora Modified: 2006-10-19 23:29 UTC (History) CC List: 7 users (show) bangerth fang gcc-bugs gdr giovannibajo pawel_sikora pinskia See Also: Host: Target: x86_64-linux Build: Known to work: Known to fail: Last reconfirmed: Attachments testcase (240 bytes, text/plain) 2006-10-19 11:54 UTC, Pawel Sikora Details View All Add an attachment (proposed patch, testcase, etc.) Note gcc error forming You need to log in before you can comment on or make changes to this bug. Description Pawel Sikora 2006-10-19 11:53:32 UTC comeau reports no error, and with stlport5 testcase works fine. $ g++ -I/usr/include/stlport main.cpp -o main -lstlport && ./main Hello 1 Hello 2 with libstdc++ i get: $ g++ main.cpp -o main && ./main /usr/include/c++/4.1.2/bits/stl_function.h: In instantiation of ‘std::binder2nd >': main.cpp:13: instantiated from here /usr/include/c++/4.1.2/bits/stl_function.h:435: error: forming reference to reference type ‘const std::string&' /usr/include/c++/4.1.2/bits/stl_function.h: In function ‘std::binder2nd<_Operation> std::bind2nd(const _Operation&, const _Tp&) [with _Operation = std::pointer_to_binary_function, _Tp = std::basic_string, std::allocator >]': main.cpp:13: instantiated from here /usr/include/c++/4.1.2/bits/stl_function.h:455: error: no matching function for call to ‘std::binder2nd >::binder2nd(const std::pointer_to_binary_function&, const std::basic_string, std::allocator >&)' /usr/include/c++/4.1.2/bits/stl_function.h:429: note: candidates are: std::binder2nd >::binder2nd(const std::binder2nd >&) Comment 1 Pawel Sikora 2006-10-19 11:54:53 UTC Created attachment 12461 [details] testcase Comment 2 Paolo Carlini 2006-10-19 13:10:51 UTC Th
I2luY2x1ZGUgPHNldD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewogICAgc3RkOjpzZXQ8aW50Jj4geDsKfQ== Compilation error #stdin compilation error #stdout 0s 0KB comments (?) stdin copy Standard input is empty compilation info /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ext/new_allocator.h: In instantiation of ‘__gnu_cxx::new_allocator’: /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/allocator.h:84: instantiated from ‘std::allocator’ /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_set.h:95: instantiated from ‘std::set, std::allocator >’ prog.cpp:6: instantiated from here /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ext/new_allocator.h:59: error: forming pointer to reference type ‘int&’ /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ext/new_allocator.h:60: error: forming pointer to reference type ‘int&’ /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ext/new_allocator.h:79: error: forming pointer to reference type ‘int&’ /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ext/new_allocator.h:82: error: forming pointer to reference type ‘int&’ /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ext/new_allocator.h:87: error: forming pointer to reference type ‘int&’ /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ext/new_allocator.h:97: error: forming pointer to reference type ‘int&’ /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ext/new_allocator.h:107: error: forming pointer to reference type ‘int&’ /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ext/new_allocator.h:118: error: forming pointer to reference type ‘int&’ /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/allocator.h: In instantiation of ‘std::allocator’: /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_set.h:95: instantiated from ‘std::set, std::allocator >’ prog.cpp:6: instantiated from here /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/allocat