Error template parameters not deducible in partial specialization

I can't figure out what I'm doing wrong! I am working on redeveloping a smart pointer class, and I'm not terribly familiar with partial specialization of templated classes. Everything looks okay, and I've checked up on the net for advice, but I think I need more 'specialized' help on this one! Here's what I've got:

I can’t figure out what I’m doing wrong! I am working on redeveloping a smart pointer class, and I’m not terribly familiar with partial specialization of templated classes. Everything looks okay, and I’ve checked up on the net for advice, but I think I need more ‘specialized’ help on this one! Here’s what I’ve got:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
enum OwnershipType	{REFERENCE_COUNTED, REFERENCE_LINKED, DESTRUCTIVE_COPY, DEEP_COPY, COPY_ON_WRITE};
enum ConversionType	{CONVERSION_NOTALLOWED = 0, CONVERSION_ALLOWED};
enum ErrorType		{ASSERT_INITIALIZE, ASSERT_DEREFERENCE, REJECT_NULL_INITIALIZE, REJECT_NULL_DEREFERENCE, NO_CHECK};
enum StorageType	{RAW_POINTER, ARRAY_POINTER, LOCKED_POINTER};

template 
	<
		typename T, 
		OwnershipType otype = REFERENCE_COUNTED, 
		ConversionType ctype = CONVERSION_NOTALLOWED, 
		ErrorType etype = ASSERT_INITIALIZE,
		StorageType stype = RAW_POINTER
	> 
class CPointer	{};

template <typename T, OwnershipType otype, ConversionType ctype, ErrorType etype, StorageType stype> class CPointer <T, REFERENCE_COUNTED, ctype, etype, stype>
{defintion...};

template <typename T, OwnershipType otype, ConversionType ctype, ErrorType etype, StorageType stype> class CPointer <T, REFERENCE_LINKED, ctype, etype, stype>
{definition...};

template <typename T, OwnershipType otype, ConversionType ctype, ErrorType etype, StorageType stype> class CPointer <T, DESTRUCTIVE_COPY, ctype, etype, stype>
{definition...};

template <typename T, OwnershipType otype, ConversionType ctype, ErrorType etype, StorageType stype> class CPointer <T, DEEP_COPY, ctype, etype, stype>
{definition...};

template <typename T, OwnershipType otype, ConversionType ctype, ErrorType etype, StorageType stype> class CPointer <T, COPY_ON_WRITE, ctype, etype, stype>
{definition...};

When I compile, I get this message (for each one of my declarations):
error C2764: ‘otype’ : template parameter not used or deducible in partial specialization ‘CPointer<T,REFERENCE_COUNTED,ctype,etype,stype>’

Now, I am using a different ‘otype’ for each definition, but I don’t need to use this ‘otype’ inside the definition since each definition is custom-made for each ‘otype’. Also, inside of each definition, when I overload operators such as =, or need to define class members, do I need to define it as:

I would like to think that I could use the latter since that would help prevent ambiguity when writing my main code. Any help is appreciated!

Bug 70141
[6 Regression] template parameter not deducible in partial specialization of template inside template

Summary:

[6 Regression] template parameter not deducible in partial specialization of …

Status: RESOLVED
FIXED

Alias:

None

Product:

gcc

Classification:

Unclassified

Component:

c++

(show other bugs)

Version:

6.0

Importance:

P1
normal

Target Milestone:

6.0

Assignee:

Jason Merrill

URL:


Keywords:

rejects-valid

Depends on:


Blocks:


Reported: 2016-03-08 16:10 UTC by Alexander Kondratskiy
Modified: 2019-11-06 07:24 UTC
(History)

CC List:

4
users

(show)

See Also:

Host:

Target:

Build:

Known to work:

4.8.5, 5.2.0

Known to fail:

6.0

Last reconfirmed:

2016-03-08 00:00:00


Attachments

Preprocessed source


(273 bytes,
text/plain)

2016-03-08 16:10 UTC,

Alexander Kondratskiy

Details

attachment-104840-0.dat


(141 bytes,
message/delivery-status)

2019-11-06 01:32 UTC,

postmaster

Details

attachment-104840-1.eml


(1.24 KB,
message/rfc822)

2019-11-06 01:32 UTC,

postmaster

Details

attachment-129895-0.dat


(141 bytes,
message/delivery-status)

2019-11-06 02:08 UTC,

postmaster

Details

attachment-129895-1.eml


(1.24 KB,
message/rfc822)

2019-11-06 02:08 UTC,

postmaster

Details

View All

Add an attachment
(proposed patch, testcase, etc.)

Note
You need to
log in
before you can comment on or make changes to this bug.


I have a similar issue like the one found here but it might happen that I am still doing something different, so I will ask none-the less.

There are some types that will be tagged with a tag structure:

template<typename Geometry=void, typename Enable = void>
struct tag
{
    typedef void type;
};

and point and triangle tags are introduced:

struct point_tag {};
struct triangle_tag {};

to construct the point type using the std::vector:

template<>
struct tag<std::vector<double>>
{
    typedef point_tag type;
};

and a triangle type as an alias template of the std::array:

template<typename Point>
using triangle =
typename std::enable_if
<
    std::is_base_of<typename tag<Point>::type, point_tag>::value,
    std::array<Point,3>
>::type;

that is enabled if the argument passed as Point parameter is really tagged with point_tag,

and afterwards, I would like to tag all triangles with the triangle_tag like this:

template <typename Point>
struct tag<triangle<Point>>
{
    typedef triangle_tag type;
};

The std::array is aliased and not composited/inherited because composition and inheritance causes problems with the initializer list construction. However, the compililation fails with the error

g++ -std=c++1y main.cpp -o main
main.cpp:31:8: error: template parameters not deducible in partial specialization:
 struct tag<triangle<Point>>
        ^
main.cpp:31:8: note:         ‘Point’

If I don’t rely on enabling the triangle based on the Point parameter being tagged, but do it for all types like this:

template<typename Point>
using triangle =
// This works, but there is no restriction on Point to be tagged with point_tag.
std::array<Point, 3>;

then the compilation works fine. However, then triangle is also a triangle, and I am using function overloading based on arbitrary properties of types to reduce the function template set from those functions for which the enable_if fails. I am not relying on container interfaces for function templates to determine the viable template arguments because sometimes the implicit interfaces are exactly the same, but the operation semantics is different. For example, a triangle is a closed circular line segment (involves operation on 3 edges), and a point chain is an open-ended line segment (involves operations on 2 edges). All operations require a direct access operator which is the only requirement for the template parameter, which leads to ambiguity in function template instantiation when they are implemented without enable_if restrictions — all covered in the linked article.

Here is the complete example.

Is there something I’m missing? How to get around this issue?


What not use your Enable template parameter ?
Something like:

template <typename Point>
struct tag<
    std::array<Point, 3>,
    typename std::enable_if<
        std::is_base_of<
            typename tag<Point>::type,
            point_tag
        >::value
    >::type
>
{
    typedef triangle_tag type;
};

(ok, you repeat the enable_if…)

Live example

  • Remove From My Forums
  • Вопрос

  • Hello,

    we have  a  C++/Cli project which uses a native C++ project.

    This native project uses boost, so by including the headers of this native project in the CLI project, boost headers are also included.

    With boost 1.68 the compiling works successfully with some warnings about boost::iostreams for the native project.

    But with boost 1.69 the compile of the C++/CLI project fails

    Error	C2764	
    'C': template parameter not used or deducible in partial specialization 'boost::is_member_function_pointer<Ret(Args...)>'
    ...includeboosttype_traitsdetailis_member_function_pointer_cxx_11.hpp	114	
    
    Warning	C4561	
    '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
    ...includeboosttype_traitsdetailis_member_function_pointer_cxx_11.hpp	120	
    
    Error	C2953	
    'boost::is_member_function_pointer<Ret(__stdcall C::* )(Args...)>': class template has already been defined
    ...includeboosttype_traitsdetailis_member_function_pointer_cxx_11.hpp	120	
    
    Warning	C4575	
    '__vectorcall' incompatible with the '/clr' option: converting to '__stdcall'
    ...includeboosttype_traitsdetailis_member_function_pointer_cxx_11.hpp	125	
    
    

    and so on.

    Are there any project settings changes I can do to get it compiled with boost 1.69 ?

    tia

      Hendrik Schmieder

    • Перемещено

      19 декабря 2018 г. 3:02
      third-party issue

Ответы

  • Just for reference.

    Boost 1.71 fixes all /clr Problems which were introduced in boost Boost 1.69

    • Помечено в качестве ответа
      h_schmieder
      9 сентября 2019 г. 12:35

Понравилась статья? Поделить с друзьями:
  • Error temp too high
  • Error temp lost перевод
  • Error temp lost antminer t17
  • Error telebot break infinity polling
  • Error telebot a request to the telegram api was unsuccessful error code 409